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
11use super::api_types::{rpc_methods, *};
12use super::session_events::SessionMode;
13use crate::session::Session;
14use crate::{Client, Error};
15
16/// Typed view over the [`Client`]'s server-level RPC namespace.
17#[derive(Clone, Copy)]
18pub struct ClientRpc<'a> {
19 pub(crate) client: &'a Client,
20}
21
22impl<'a> ClientRpc<'a> {
23 /// `account.*` sub-namespace.
24 pub fn account(&self) -> ClientRpcAccount<'a> {
25 ClientRpcAccount {
26 client: self.client,
27 }
28 }
29
30 /// `mcp.*` sub-namespace.
31 pub fn mcp(&self) -> ClientRpcMcp<'a> {
32 ClientRpcMcp {
33 client: self.client,
34 }
35 }
36
37 /// `models.*` sub-namespace.
38 pub fn models(&self) -> ClientRpcModels<'a> {
39 ClientRpcModels {
40 client: self.client,
41 }
42 }
43
44 /// `sessionFs.*` sub-namespace.
45 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
46 ClientRpcSessionFs {
47 client: self.client,
48 }
49 }
50
51 /// `sessions.*` sub-namespace.
52 pub fn sessions(&self) -> ClientRpcSessions<'a> {
53 ClientRpcSessions {
54 client: self.client,
55 }
56 }
57
58 /// `skills.*` sub-namespace.
59 pub fn skills(&self) -> ClientRpcSkills<'a> {
60 ClientRpcSkills {
61 client: self.client,
62 }
63 }
64
65 /// `tools.*` sub-namespace.
66 pub fn tools(&self) -> ClientRpcTools<'a> {
67 ClientRpcTools {
68 client: self.client,
69 }
70 }
71
72 /// Checks server responsiveness and returns protocol information.
73 ///
74 /// Wire method: `ping`.
75 ///
76 /// # Parameters
77 ///
78 /// * `params` - Optional message to echo back to the caller.
79 ///
80 /// # Returns
81 ///
82 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
83 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
84 let wire_params = serde_json::to_value(params)?;
85 let _value = self
86 .client
87 .call(rpc_methods::PING, Some(wire_params))
88 .await?;
89 Ok(serde_json::from_value(_value)?)
90 }
91
92 /// Performs the SDK server connection handshake and validates the optional connection token.
93 ///
94 /// Wire method: `connect`.
95 ///
96 /// # Parameters
97 ///
98 /// * `params` - Optional connection token presented by the SDK client during the handshake.
99 ///
100 /// # Returns
101 ///
102 /// Handshake result reporting the server's protocol version and package version on success.
103 pub async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
104 let wire_params = serde_json::to_value(params)?;
105 let _value = self
106 .client
107 .call(rpc_methods::CONNECT, Some(wire_params))
108 .await?;
109 Ok(serde_json::from_value(_value)?)
110 }
111}
112
113/// `account.*` RPCs.
114#[derive(Clone, Copy)]
115pub struct ClientRpcAccount<'a> {
116 pub(crate) client: &'a Client,
117}
118
119impl<'a> ClientRpcAccount<'a> {
120 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
121 ///
122 /// Wire method: `account.getQuota`.
123 ///
124 /// # Returns
125 ///
126 /// Quota usage snapshots for the resolved user, keyed by quota type.
127 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
128 let wire_params = serde_json::json!({});
129 let _value = self
130 .client
131 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
132 .await?;
133 Ok(serde_json::from_value(_value)?)
134 }
135
136 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
137 ///
138 /// Wire method: `account.getQuota`.
139 ///
140 /// # Parameters
141 ///
142 /// * `params` - Optional GitHub token used to look up quota for a specific user instead of the global auth context.
143 ///
144 /// # Returns
145 ///
146 /// Quota usage snapshots for the resolved user, keyed by quota type.
147 pub async fn get_quota_with_params(
148 &self,
149 params: AccountGetQuotaRequest,
150 ) -> Result<AccountGetQuotaResult, Error> {
151 let wire_params = serde_json::to_value(params)?;
152 let _value = self
153 .client
154 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
155 .await?;
156 Ok(serde_json::from_value(_value)?)
157 }
158}
159
160/// `mcp.*` RPCs.
161#[derive(Clone, Copy)]
162pub struct ClientRpcMcp<'a> {
163 pub(crate) client: &'a Client,
164}
165
166impl<'a> ClientRpcMcp<'a> {
167 /// `mcp.config.*` sub-namespace.
168 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
169 ClientRpcMcpConfig {
170 client: self.client,
171 }
172 }
173
174 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
175 ///
176 /// Wire method: `mcp.discover`.
177 ///
178 /// # Parameters
179 ///
180 /// * `params` - Optional working directory used as context for MCP server discovery.
181 ///
182 /// # Returns
183 ///
184 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
185 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
186 let wire_params = serde_json::to_value(params)?;
187 let _value = self
188 .client
189 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
190 .await?;
191 Ok(serde_json::from_value(_value)?)
192 }
193}
194
195/// `mcp.config.*` RPCs.
196#[derive(Clone, Copy)]
197pub struct ClientRpcMcpConfig<'a> {
198 pub(crate) client: &'a Client,
199}
200
201impl<'a> ClientRpcMcpConfig<'a> {
202 /// Lists MCP servers from user configuration.
203 ///
204 /// Wire method: `mcp.config.list`.
205 ///
206 /// # Returns
207 ///
208 /// User-configured MCP servers, keyed by server name.
209 pub async fn list(&self) -> Result<McpConfigList, Error> {
210 let wire_params = serde_json::json!({});
211 let _value = self
212 .client
213 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
214 .await?;
215 Ok(serde_json::from_value(_value)?)
216 }
217
218 /// Adds an MCP server to user configuration.
219 ///
220 /// Wire method: `mcp.config.add`.
221 ///
222 /// # Parameters
223 ///
224 /// * `params` - MCP server name and configuration to add to user configuration.
225 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
226 let wire_params = serde_json::to_value(params)?;
227 let _value = self
228 .client
229 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
230 .await?;
231 Ok(())
232 }
233
234 /// Updates an MCP server in user configuration.
235 ///
236 /// Wire method: `mcp.config.update`.
237 ///
238 /// # Parameters
239 ///
240 /// * `params` - MCP server name and replacement configuration to write to user configuration.
241 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
242 let wire_params = serde_json::to_value(params)?;
243 let _value = self
244 .client
245 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
246 .await?;
247 Ok(())
248 }
249
250 /// Removes an MCP server from user configuration.
251 ///
252 /// Wire method: `mcp.config.remove`.
253 ///
254 /// # Parameters
255 ///
256 /// * `params` - MCP server name to remove from user configuration.
257 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
258 let wire_params = serde_json::to_value(params)?;
259 let _value = self
260 .client
261 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
262 .await?;
263 Ok(())
264 }
265
266 /// Enables MCP servers in user configuration for new sessions.
267 ///
268 /// Wire method: `mcp.config.enable`.
269 ///
270 /// # Parameters
271 ///
272 /// * `params` - MCP server names to enable for new sessions.
273 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
274 let wire_params = serde_json::to_value(params)?;
275 let _value = self
276 .client
277 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
278 .await?;
279 Ok(())
280 }
281
282 /// Disables MCP servers in user configuration for new sessions.
283 ///
284 /// Wire method: `mcp.config.disable`.
285 ///
286 /// # Parameters
287 ///
288 /// * `params` - MCP server names to disable for new sessions.
289 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
290 let wire_params = serde_json::to_value(params)?;
291 let _value = self
292 .client
293 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
294 .await?;
295 Ok(())
296 }
297}
298
299/// `models.*` RPCs.
300#[derive(Clone, Copy)]
301pub struct ClientRpcModels<'a> {
302 pub(crate) client: &'a Client,
303}
304
305impl<'a> ClientRpcModels<'a> {
306 /// Lists Copilot models available to the authenticated user.
307 ///
308 /// Wire method: `models.list`.
309 ///
310 /// # Returns
311 ///
312 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
313 pub async fn list(&self) -> Result<ModelList, Error> {
314 let wire_params = serde_json::json!({});
315 let _value = self
316 .client
317 .call(rpc_methods::MODELS_LIST, Some(wire_params))
318 .await?;
319 Ok(serde_json::from_value(_value)?)
320 }
321
322 /// Lists Copilot models available to the authenticated user.
323 ///
324 /// Wire method: `models.list`.
325 ///
326 /// # Parameters
327 ///
328 /// * `params` - Optional GitHub token used to list models for a specific user instead of the global auth context.
329 ///
330 /// # Returns
331 ///
332 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
333 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
334 let wire_params = serde_json::to_value(params)?;
335 let _value = self
336 .client
337 .call(rpc_methods::MODELS_LIST, Some(wire_params))
338 .await?;
339 Ok(serde_json::from_value(_value)?)
340 }
341}
342
343/// `sessionFs.*` RPCs.
344#[derive(Clone, Copy)]
345pub struct ClientRpcSessionFs<'a> {
346 pub(crate) client: &'a Client,
347}
348
349impl<'a> ClientRpcSessionFs<'a> {
350 /// Registers an SDK client as the session filesystem provider.
351 ///
352 /// Wire method: `sessionFs.setProvider`.
353 ///
354 /// # Parameters
355 ///
356 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
357 ///
358 /// # Returns
359 ///
360 /// Indicates whether the calling client was registered as the session filesystem provider.
361 pub async fn set_provider(
362 &self,
363 params: SessionFsSetProviderRequest,
364 ) -> Result<SessionFsSetProviderResult, Error> {
365 let wire_params = serde_json::to_value(params)?;
366 let _value = self
367 .client
368 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
369 .await?;
370 Ok(serde_json::from_value(_value)?)
371 }
372}
373
374/// `sessions.*` RPCs.
375#[derive(Clone, Copy)]
376pub struct ClientRpcSessions<'a> {
377 pub(crate) client: &'a Client,
378}
379
380impl<'a> ClientRpcSessions<'a> {
381 /// Creates a new session by forking persisted history from an existing session.
382 ///
383 /// Wire method: `sessions.fork`.
384 ///
385 /// # Parameters
386 ///
387 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
388 ///
389 /// # Returns
390 ///
391 /// Identifier and optional friendly name assigned to the newly forked session.
392 ///
393 /// <div class="warning">
394 ///
395 /// **Experimental.** This API is part of an experimental wire-protocol surface
396 /// and may change or be removed in future SDK or CLI releases. Pin both the
397 /// SDK and CLI versions if your code depends on it.
398 ///
399 /// </div>
400 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
401 let wire_params = serde_json::to_value(params)?;
402 let _value = self
403 .client
404 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
405 .await?;
406 Ok(serde_json::from_value(_value)?)
407 }
408
409 /// Connects to an existing remote session and exposes it as an SDK session.
410 ///
411 /// Wire method: `sessions.connect`.
412 ///
413 /// # Parameters
414 ///
415 /// * `params` - Remote session connection parameters.
416 ///
417 /// # Returns
418 ///
419 /// Remote session connection result.
420 ///
421 /// <div class="warning">
422 ///
423 /// **Experimental.** This API is part of an experimental wire-protocol surface
424 /// and may change or be removed in future SDK or CLI releases. Pin both the
425 /// SDK and CLI versions if your code depends on it.
426 ///
427 /// </div>
428 pub async fn connect(
429 &self,
430 params: ConnectRemoteSessionParams,
431 ) -> Result<RemoteSessionConnectionResult, Error> {
432 let wire_params = serde_json::to_value(params)?;
433 let _value = self
434 .client
435 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
436 .await?;
437 Ok(serde_json::from_value(_value)?)
438 }
439
440 /// Lists persisted sessions, optionally filtered by working-directory context.
441 ///
442 /// Wire method: `sessions.list`.
443 ///
444 /// # Returns
445 ///
446 /// Persisted sessions matching the filter, ordered most-recently-modified first.
447 ///
448 /// <div class="warning">
449 ///
450 /// **Experimental.** This API is part of an experimental wire-protocol surface
451 /// and may change or be removed in future SDK or CLI releases. Pin both the
452 /// SDK and CLI versions if your code depends on it.
453 ///
454 /// </div>
455 pub async fn list(&self) -> Result<SessionList, Error> {
456 let wire_params = serde_json::json!({});
457 let _value = self
458 .client
459 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
460 .await?;
461 Ok(serde_json::from_value(_value)?)
462 }
463
464 /// Lists persisted sessions, optionally filtered by working-directory context.
465 ///
466 /// Wire method: `sessions.list`.
467 ///
468 /// # Parameters
469 ///
470 /// * `params` - Optional metadata-load limit and context filter applied to the returned sessions.
471 ///
472 /// # Returns
473 ///
474 /// Persisted sessions matching the filter, ordered most-recently-modified first.
475 ///
476 /// <div class="warning">
477 ///
478 /// **Experimental.** This API is part of an experimental wire-protocol surface
479 /// and may change or be removed in future SDK or CLI releases. Pin both the
480 /// SDK and CLI versions if your code depends on it.
481 ///
482 /// </div>
483 pub async fn list_with_params(
484 &self,
485 params: SessionsListRequest,
486 ) -> Result<SessionList, Error> {
487 let wire_params = serde_json::to_value(params)?;
488 let _value = self
489 .client
490 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
491 .await?;
492 Ok(serde_json::from_value(_value)?)
493 }
494
495 /// Finds the local session bound to a GitHub task ID, if any.
496 ///
497 /// Wire method: `sessions.findByTaskId`.
498 ///
499 /// # Parameters
500 ///
501 /// * `params` - GitHub task ID to look up.
502 ///
503 /// # Returns
504 ///
505 /// ID of the local session bound to the given GitHub task, or omitted when none.
506 ///
507 /// <div class="warning">
508 ///
509 /// **Experimental.** This API is part of an experimental wire-protocol surface
510 /// and may change or be removed in future SDK or CLI releases. Pin both the
511 /// SDK and CLI versions if your code depends on it.
512 ///
513 /// </div>
514 pub async fn find_by_task_id(
515 &self,
516 params: SessionsFindByTaskIDRequest,
517 ) -> Result<SessionsFindByTaskIDResult, Error> {
518 let wire_params = serde_json::to_value(params)?;
519 let _value = self
520 .client
521 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
522 .await?;
523 Ok(serde_json::from_value(_value)?)
524 }
525
526 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
527 ///
528 /// Wire method: `sessions.findByPrefix`.
529 ///
530 /// # Parameters
531 ///
532 /// * `params` - UUID prefix to resolve to a unique session ID.
533 ///
534 /// # Returns
535 ///
536 /// Session ID matching the prefix, omitted when no unique match exists.
537 ///
538 /// <div class="warning">
539 ///
540 /// **Experimental.** This API is part of an experimental wire-protocol surface
541 /// and may change or be removed in future SDK or CLI releases. Pin both the
542 /// SDK and CLI versions if your code depends on it.
543 ///
544 /// </div>
545 pub async fn find_by_prefix(
546 &self,
547 params: SessionsFindByPrefixRequest,
548 ) -> Result<SessionsFindByPrefixResult, Error> {
549 let wire_params = serde_json::to_value(params)?;
550 let _value = self
551 .client
552 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
553 .await?;
554 Ok(serde_json::from_value(_value)?)
555 }
556
557 /// Returns the most-relevant prior session for a given working-directory context.
558 ///
559 /// Wire method: `sessions.getLastForContext`.
560 ///
561 /// # Parameters
562 ///
563 /// * `params` - Optional working-directory context used to score session relevance.
564 ///
565 /// # Returns
566 ///
567 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
568 ///
569 /// <div class="warning">
570 ///
571 /// **Experimental.** This API is part of an experimental wire-protocol surface
572 /// and may change or be removed in future SDK or CLI releases. Pin both the
573 /// SDK and CLI versions if your code depends on it.
574 ///
575 /// </div>
576 pub async fn get_last_for_context(
577 &self,
578 params: SessionsGetLastForContextRequest,
579 ) -> Result<SessionsGetLastForContextResult, Error> {
580 let wire_params = serde_json::to_value(params)?;
581 let _value = self
582 .client
583 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
584 .await?;
585 Ok(serde_json::from_value(_value)?)
586 }
587
588 /// Computes the absolute path to a session's persisted events.jsonl file.
589 ///
590 /// Wire method: `sessions.getEventFilePath`.
591 ///
592 /// # Parameters
593 ///
594 /// * `params` - Session ID whose event-log file path to compute.
595 ///
596 /// # Returns
597 ///
598 /// Absolute path to the session's events.jsonl file on disk.
599 ///
600 /// <div class="warning">
601 ///
602 /// **Experimental.** This API is part of an experimental wire-protocol surface
603 /// and may change or be removed in future SDK or CLI releases. Pin both the
604 /// SDK and CLI versions if your code depends on it.
605 ///
606 /// </div>
607 pub async fn get_event_file_path(
608 &self,
609 params: SessionsGetEventFilePathRequest,
610 ) -> Result<SessionsGetEventFilePathResult, Error> {
611 let wire_params = serde_json::to_value(params)?;
612 let _value = self
613 .client
614 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
615 .await?;
616 Ok(serde_json::from_value(_value)?)
617 }
618
619 /// Returns the on-disk byte size of each session's workspace directory.
620 ///
621 /// Wire method: `sessions.getSizes`.
622 ///
623 /// # Returns
624 ///
625 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
626 ///
627 /// <div class="warning">
628 ///
629 /// **Experimental.** This API is part of an experimental wire-protocol surface
630 /// and may change or be removed in future SDK or CLI releases. Pin both the
631 /// SDK and CLI versions if your code depends on it.
632 ///
633 /// </div>
634 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
635 let wire_params = serde_json::json!({});
636 let _value = self
637 .client
638 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
639 .await?;
640 Ok(serde_json::from_value(_value)?)
641 }
642
643 /// Returns the subset of the supplied session IDs that are currently held by another running process.
644 ///
645 /// Wire method: `sessions.checkInUse`.
646 ///
647 /// # Parameters
648 ///
649 /// * `params` - Session IDs to test for live in-use locks.
650 ///
651 /// # Returns
652 ///
653 /// Session IDs from the input set that are currently in use by another process.
654 ///
655 /// <div class="warning">
656 ///
657 /// **Experimental.** This API is part of an experimental wire-protocol surface
658 /// and may change or be removed in future SDK or CLI releases. Pin both the
659 /// SDK and CLI versions if your code depends on it.
660 ///
661 /// </div>
662 pub async fn check_in_use(
663 &self,
664 params: SessionsCheckInUseRequest,
665 ) -> Result<SessionsCheckInUseResult, Error> {
666 let wire_params = serde_json::to_value(params)?;
667 let _value = self
668 .client
669 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
670 .await?;
671 Ok(serde_json::from_value(_value)?)
672 }
673
674 /// Returns a session's persisted remote-steerable flag, if any has been recorded.
675 ///
676 /// Wire method: `sessions.getPersistedRemoteSteerable`.
677 ///
678 /// # Parameters
679 ///
680 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
681 ///
682 /// # Returns
683 ///
684 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
685 ///
686 /// <div class="warning">
687 ///
688 /// **Experimental.** This API is part of an experimental wire-protocol surface
689 /// and may change or be removed in future SDK or CLI releases. Pin both the
690 /// SDK and CLI versions if your code depends on it.
691 ///
692 /// </div>
693 pub async fn get_persisted_remote_steerable(
694 &self,
695 params: SessionsGetPersistedRemoteSteerableRequest,
696 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
697 let wire_params = serde_json::to_value(params)?;
698 let _value = self
699 .client
700 .call(
701 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
702 Some(wire_params),
703 )
704 .await?;
705 Ok(serde_json::from_value(_value)?)
706 }
707
708 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
709 ///
710 /// Wire method: `sessions.close`.
711 ///
712 /// # Parameters
713 ///
714 /// * `params` - Session ID to close.
715 ///
716 /// # Returns
717 ///
718 /// 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.
719 ///
720 /// <div class="warning">
721 ///
722 /// **Experimental.** This API is part of an experimental wire-protocol surface
723 /// and may change or be removed in future SDK or CLI releases. Pin both the
724 /// SDK and CLI versions if your code depends on it.
725 ///
726 /// </div>
727 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
728 let wire_params = serde_json::to_value(params)?;
729 let _value = self
730 .client
731 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
732 .await?;
733 Ok(serde_json::from_value(_value)?)
734 }
735
736 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
737 ///
738 /// Wire method: `sessions.bulkDelete`.
739 ///
740 /// # Parameters
741 ///
742 /// * `params` - Session IDs to close, deactivate, and delete from disk.
743 ///
744 /// # Returns
745 ///
746 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
747 ///
748 /// <div class="warning">
749 ///
750 /// **Experimental.** This API is part of an experimental wire-protocol surface
751 /// and may change or be removed in future SDK or CLI releases. Pin both the
752 /// SDK and CLI versions if your code depends on it.
753 ///
754 /// </div>
755 pub async fn bulk_delete(
756 &self,
757 params: SessionsBulkDeleteRequest,
758 ) -> Result<SessionBulkDeleteResult, Error> {
759 let wire_params = serde_json::to_value(params)?;
760 let _value = self
761 .client
762 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
763 .await?;
764 Ok(serde_json::from_value(_value)?)
765 }
766
767 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
768 ///
769 /// Wire method: `sessions.pruneOld`.
770 ///
771 /// # Parameters
772 ///
773 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
774 ///
775 /// # Returns
776 ///
777 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
778 ///
779 /// <div class="warning">
780 ///
781 /// **Experimental.** This API is part of an experimental wire-protocol surface
782 /// and may change or be removed in future SDK or CLI releases. Pin both the
783 /// SDK and CLI versions if your code depends on it.
784 ///
785 /// </div>
786 pub async fn prune_old(
787 &self,
788 params: SessionsPruneOldRequest,
789 ) -> Result<SessionPruneResult, Error> {
790 let wire_params = serde_json::to_value(params)?;
791 let _value = self
792 .client
793 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
794 .await?;
795 Ok(serde_json::from_value(_value)?)
796 }
797
798 /// Flushes a session's pending events to disk.
799 ///
800 /// Wire method: `sessions.save`.
801 ///
802 /// # Parameters
803 ///
804 /// * `params` - Session ID whose pending events should be flushed to disk.
805 ///
806 /// # Returns
807 ///
808 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
809 ///
810 /// <div class="warning">
811 ///
812 /// **Experimental.** This API is part of an experimental wire-protocol surface
813 /// and may change or be removed in future SDK or CLI releases. Pin both the
814 /// SDK and CLI versions if your code depends on it.
815 ///
816 /// </div>
817 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
818 let wire_params = serde_json::to_value(params)?;
819 let _value = self
820 .client
821 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
822 .await?;
823 Ok(serde_json::from_value(_value)?)
824 }
825
826 /// Releases the in-use lock held by this process for a session.
827 ///
828 /// Wire method: `sessions.releaseLock`.
829 ///
830 /// # Parameters
831 ///
832 /// * `params` - Session ID whose in-use lock should be released.
833 ///
834 /// # Returns
835 ///
836 /// 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.
837 ///
838 /// <div class="warning">
839 ///
840 /// **Experimental.** This API is part of an experimental wire-protocol surface
841 /// and may change or be removed in future SDK or CLI releases. Pin both the
842 /// SDK and CLI versions if your code depends on it.
843 ///
844 /// </div>
845 pub async fn release_lock(
846 &self,
847 params: SessionsReleaseLockRequest,
848 ) -> Result<SessionsReleaseLockResult, Error> {
849 let wire_params = serde_json::to_value(params)?;
850 let _value = self
851 .client
852 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
853 .await?;
854 Ok(serde_json::from_value(_value)?)
855 }
856
857 /// Backfills missing summary and context fields on the supplied session metadata records.
858 ///
859 /// Wire method: `sessions.enrichMetadata`.
860 ///
861 /// # Parameters
862 ///
863 /// * `params` - Session metadata records to enrich with summary and context information.
864 ///
865 /// # Returns
866 ///
867 /// The same metadata records, with summary and context fields backfilled where available.
868 ///
869 /// <div class="warning">
870 ///
871 /// **Experimental.** This API is part of an experimental wire-protocol surface
872 /// and may change or be removed in future SDK or CLI releases. Pin both the
873 /// SDK and CLI versions if your code depends on it.
874 ///
875 /// </div>
876 pub async fn enrich_metadata(
877 &self,
878 params: SessionsEnrichMetadataRequest,
879 ) -> Result<SessionEnrichMetadataResult, Error> {
880 let wire_params = serde_json::to_value(params)?;
881 let _value = self
882 .client
883 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
884 .await?;
885 Ok(serde_json::from_value(_value)?)
886 }
887
888 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
889 ///
890 /// Wire method: `sessions.reloadPluginHooks`.
891 ///
892 /// # Parameters
893 ///
894 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
895 ///
896 /// # Returns
897 ///
898 /// 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.
899 ///
900 /// <div class="warning">
901 ///
902 /// **Experimental.** This API is part of an experimental wire-protocol surface
903 /// and may change or be removed in future SDK or CLI releases. Pin both the
904 /// SDK and CLI versions if your code depends on it.
905 ///
906 /// </div>
907 pub async fn reload_plugin_hooks(
908 &self,
909 params: SessionsReloadPluginHooksRequest,
910 ) -> Result<SessionsReloadPluginHooksResult, Error> {
911 let wire_params = serde_json::to_value(params)?;
912 let _value = self
913 .client
914 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
915 .await?;
916 Ok(serde_json::from_value(_value)?)
917 }
918
919 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
920 ///
921 /// Wire method: `sessions.loadDeferredRepoHooks`.
922 ///
923 /// # Parameters
924 ///
925 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
926 ///
927 /// # Returns
928 ///
929 /// Queued repo-level startup prompts and the total hook command count after loading.
930 ///
931 /// <div class="warning">
932 ///
933 /// **Experimental.** This API is part of an experimental wire-protocol surface
934 /// and may change or be removed in future SDK or CLI releases. Pin both the
935 /// SDK and CLI versions if your code depends on it.
936 ///
937 /// </div>
938 pub async fn load_deferred_repo_hooks(
939 &self,
940 params: SessionsLoadDeferredRepoHooksRequest,
941 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
942 let wire_params = serde_json::to_value(params)?;
943 let _value = self
944 .client
945 .call(
946 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
947 Some(wire_params),
948 )
949 .await?;
950 Ok(serde_json::from_value(_value)?)
951 }
952
953 /// Replaces the manager-wide additional plugins registered with the session manager.
954 ///
955 /// Wire method: `sessions.setAdditionalPlugins`.
956 ///
957 /// # Parameters
958 ///
959 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
960 ///
961 /// # Returns
962 ///
963 /// 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.
964 ///
965 /// <div class="warning">
966 ///
967 /// **Experimental.** This API is part of an experimental wire-protocol surface
968 /// and may change or be removed in future SDK or CLI releases. Pin both the
969 /// SDK and CLI versions if your code depends on it.
970 ///
971 /// </div>
972 pub async fn set_additional_plugins(
973 &self,
974 params: SessionsSetAdditionalPluginsRequest,
975 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
976 let wire_params = serde_json::to_value(params)?;
977 let _value = self
978 .client
979 .call(
980 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
981 Some(wire_params),
982 )
983 .await?;
984 Ok(serde_json::from_value(_value)?)
985 }
986}
987
988/// `skills.*` RPCs.
989#[derive(Clone, Copy)]
990pub struct ClientRpcSkills<'a> {
991 pub(crate) client: &'a Client,
992}
993
994impl<'a> ClientRpcSkills<'a> {
995 /// `skills.config.*` sub-namespace.
996 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
997 ClientRpcSkillsConfig {
998 client: self.client,
999 }
1000 }
1001
1002 /// Discovers skills across global and project sources.
1003 ///
1004 /// Wire method: `skills.discover`.
1005 ///
1006 /// # Parameters
1007 ///
1008 /// * `params` - Optional project paths and additional skill directories to include in discovery.
1009 ///
1010 /// # Returns
1011 ///
1012 /// Skills discovered across global and project sources.
1013 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
1014 let wire_params = serde_json::to_value(params)?;
1015 let _value = self
1016 .client
1017 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
1018 .await?;
1019 Ok(serde_json::from_value(_value)?)
1020 }
1021}
1022
1023/// `skills.config.*` RPCs.
1024#[derive(Clone, Copy)]
1025pub struct ClientRpcSkillsConfig<'a> {
1026 pub(crate) client: &'a Client,
1027}
1028
1029impl<'a> ClientRpcSkillsConfig<'a> {
1030 /// Replaces the global list of disabled skills.
1031 ///
1032 /// Wire method: `skills.config.setDisabledSkills`.
1033 ///
1034 /// # Parameters
1035 ///
1036 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
1037 pub async fn set_disabled_skills(
1038 &self,
1039 params: SkillsConfigSetDisabledSkillsRequest,
1040 ) -> Result<(), Error> {
1041 let wire_params = serde_json::to_value(params)?;
1042 let _value = self
1043 .client
1044 .call(
1045 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
1046 Some(wire_params),
1047 )
1048 .await?;
1049 Ok(())
1050 }
1051}
1052
1053/// `tools.*` RPCs.
1054#[derive(Clone, Copy)]
1055pub struct ClientRpcTools<'a> {
1056 pub(crate) client: &'a Client,
1057}
1058
1059impl<'a> ClientRpcTools<'a> {
1060 /// Lists built-in tools available for a model.
1061 ///
1062 /// Wire method: `tools.list`.
1063 ///
1064 /// # Parameters
1065 ///
1066 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
1067 ///
1068 /// # Returns
1069 ///
1070 /// Built-in tools available for the requested model, with their parameters and instructions.
1071 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
1072 let wire_params = serde_json::to_value(params)?;
1073 let _value = self
1074 .client
1075 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
1076 .await?;
1077 Ok(serde_json::from_value(_value)?)
1078 }
1079}
1080
1081/// Typed view over a [`Session`]'s RPC namespace.
1082#[derive(Clone, Copy)]
1083pub struct SessionRpc<'a> {
1084 pub(crate) session: &'a Session,
1085}
1086
1087impl<'a> SessionRpc<'a> {
1088 /// `session.agent.*` sub-namespace.
1089 pub fn agent(&self) -> SessionRpcAgent<'a> {
1090 SessionRpcAgent {
1091 session: self.session,
1092 }
1093 }
1094
1095 /// `session.auth.*` sub-namespace.
1096 pub fn auth(&self) -> SessionRpcAuth<'a> {
1097 SessionRpcAuth {
1098 session: self.session,
1099 }
1100 }
1101
1102 /// `session.commands.*` sub-namespace.
1103 pub fn commands(&self) -> SessionRpcCommands<'a> {
1104 SessionRpcCommands {
1105 session: self.session,
1106 }
1107 }
1108
1109 /// `session.eventLog.*` sub-namespace.
1110 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
1111 SessionRpcEventLog {
1112 session: self.session,
1113 }
1114 }
1115
1116 /// `session.extensions.*` sub-namespace.
1117 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
1118 SessionRpcExtensions {
1119 session: self.session,
1120 }
1121 }
1122
1123 /// `session.fleet.*` sub-namespace.
1124 pub fn fleet(&self) -> SessionRpcFleet<'a> {
1125 SessionRpcFleet {
1126 session: self.session,
1127 }
1128 }
1129
1130 /// `session.history.*` sub-namespace.
1131 pub fn history(&self) -> SessionRpcHistory<'a> {
1132 SessionRpcHistory {
1133 session: self.session,
1134 }
1135 }
1136
1137 /// `session.instructions.*` sub-namespace.
1138 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
1139 SessionRpcInstructions {
1140 session: self.session,
1141 }
1142 }
1143
1144 /// `session.lsp.*` sub-namespace.
1145 pub fn lsp(&self) -> SessionRpcLsp<'a> {
1146 SessionRpcLsp {
1147 session: self.session,
1148 }
1149 }
1150
1151 /// `session.mcp.*` sub-namespace.
1152 pub fn mcp(&self) -> SessionRpcMcp<'a> {
1153 SessionRpcMcp {
1154 session: self.session,
1155 }
1156 }
1157
1158 /// `session.metadata.*` sub-namespace.
1159 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
1160 SessionRpcMetadata {
1161 session: self.session,
1162 }
1163 }
1164
1165 /// `session.mode.*` sub-namespace.
1166 pub fn mode(&self) -> SessionRpcMode<'a> {
1167 SessionRpcMode {
1168 session: self.session,
1169 }
1170 }
1171
1172 /// `session.model.*` sub-namespace.
1173 pub fn model(&self) -> SessionRpcModel<'a> {
1174 SessionRpcModel {
1175 session: self.session,
1176 }
1177 }
1178
1179 /// `session.name.*` sub-namespace.
1180 pub fn name(&self) -> SessionRpcName<'a> {
1181 SessionRpcName {
1182 session: self.session,
1183 }
1184 }
1185
1186 /// `session.options.*` sub-namespace.
1187 pub fn options(&self) -> SessionRpcOptions<'a> {
1188 SessionRpcOptions {
1189 session: self.session,
1190 }
1191 }
1192
1193 /// `session.permissions.*` sub-namespace.
1194 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
1195 SessionRpcPermissions {
1196 session: self.session,
1197 }
1198 }
1199
1200 /// `session.plan.*` sub-namespace.
1201 pub fn plan(&self) -> SessionRpcPlan<'a> {
1202 SessionRpcPlan {
1203 session: self.session,
1204 }
1205 }
1206
1207 /// `session.plugins.*` sub-namespace.
1208 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
1209 SessionRpcPlugins {
1210 session: self.session,
1211 }
1212 }
1213
1214 /// `session.queue.*` sub-namespace.
1215 pub fn queue(&self) -> SessionRpcQueue<'a> {
1216 SessionRpcQueue {
1217 session: self.session,
1218 }
1219 }
1220
1221 /// `session.remote.*` sub-namespace.
1222 pub fn remote(&self) -> SessionRpcRemote<'a> {
1223 SessionRpcRemote {
1224 session: self.session,
1225 }
1226 }
1227
1228 /// `session.schedule.*` sub-namespace.
1229 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
1230 SessionRpcSchedule {
1231 session: self.session,
1232 }
1233 }
1234
1235 /// `session.shell.*` sub-namespace.
1236 pub fn shell(&self) -> SessionRpcShell<'a> {
1237 SessionRpcShell {
1238 session: self.session,
1239 }
1240 }
1241
1242 /// `session.skills.*` sub-namespace.
1243 pub fn skills(&self) -> SessionRpcSkills<'a> {
1244 SessionRpcSkills {
1245 session: self.session,
1246 }
1247 }
1248
1249 /// `session.tasks.*` sub-namespace.
1250 pub fn tasks(&self) -> SessionRpcTasks<'a> {
1251 SessionRpcTasks {
1252 session: self.session,
1253 }
1254 }
1255
1256 /// `session.telemetry.*` sub-namespace.
1257 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
1258 SessionRpcTelemetry {
1259 session: self.session,
1260 }
1261 }
1262
1263 /// `session.tools.*` sub-namespace.
1264 pub fn tools(&self) -> SessionRpcTools<'a> {
1265 SessionRpcTools {
1266 session: self.session,
1267 }
1268 }
1269
1270 /// `session.ui.*` sub-namespace.
1271 pub fn ui(&self) -> SessionRpcUi<'a> {
1272 SessionRpcUi {
1273 session: self.session,
1274 }
1275 }
1276
1277 /// `session.usage.*` sub-namespace.
1278 pub fn usage(&self) -> SessionRpcUsage<'a> {
1279 SessionRpcUsage {
1280 session: self.session,
1281 }
1282 }
1283
1284 /// `session.workspaces.*` sub-namespace.
1285 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
1286 SessionRpcWorkspaces {
1287 session: self.session,
1288 }
1289 }
1290
1291 /// Suspends the session while preserving persisted state for later resume.
1292 ///
1293 /// Wire method: `session.suspend`.
1294 ///
1295 /// <div class="warning">
1296 ///
1297 /// **Experimental.** This API is part of an experimental wire-protocol surface
1298 /// and may change or be removed in future SDK or CLI releases. Pin both the
1299 /// SDK and CLI versions if your code depends on it.
1300 ///
1301 /// </div>
1302 pub async fn suspend(&self) -> Result<(), Error> {
1303 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1304 let _value = self
1305 .session
1306 .client()
1307 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
1308 .await?;
1309 Ok(())
1310 }
1311
1312 /// Sends a user message to the session and returns its message ID.
1313 ///
1314 /// Wire method: `session.send`.
1315 ///
1316 /// # Parameters
1317 ///
1318 /// * `params` - Parameters for sending a user message to the session
1319 ///
1320 /// # Returns
1321 ///
1322 /// Result of sending a user message
1323 ///
1324 /// <div class="warning">
1325 ///
1326 /// **Experimental.** This API is part of an experimental wire-protocol surface
1327 /// and may change or be removed in future SDK or CLI releases. Pin both the
1328 /// SDK and CLI versions if your code depends on it.
1329 ///
1330 /// </div>
1331 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
1332 let mut wire_params = serde_json::to_value(params)?;
1333 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1334 let _value = self
1335 .session
1336 .client()
1337 .call(rpc_methods::SESSION_SEND, Some(wire_params))
1338 .await?;
1339 Ok(serde_json::from_value(_value)?)
1340 }
1341
1342 /// Aborts the current agent turn.
1343 ///
1344 /// Wire method: `session.abort`.
1345 ///
1346 /// # Parameters
1347 ///
1348 /// * `params` - Parameters for aborting the current turn
1349 ///
1350 /// # Returns
1351 ///
1352 /// Result of aborting the current turn
1353 ///
1354 /// <div class="warning">
1355 ///
1356 /// **Experimental.** This API is part of an experimental wire-protocol surface
1357 /// and may change or be removed in future SDK or CLI releases. Pin both the
1358 /// SDK and CLI versions if your code depends on it.
1359 ///
1360 /// </div>
1361 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
1362 let mut wire_params = serde_json::to_value(params)?;
1363 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1364 let _value = self
1365 .session
1366 .client()
1367 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
1368 .await?;
1369 Ok(serde_json::from_value(_value)?)
1370 }
1371
1372 /// 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.
1373 ///
1374 /// Wire method: `session.shutdown`.
1375 ///
1376 /// # Parameters
1377 ///
1378 /// * `params` - Parameters for shutting down the session
1379 ///
1380 /// <div class="warning">
1381 ///
1382 /// **Experimental.** This API is part of an experimental wire-protocol surface
1383 /// and may change or be removed in future SDK or CLI releases. Pin both the
1384 /// SDK and CLI versions if your code depends on it.
1385 ///
1386 /// </div>
1387 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
1388 let mut wire_params = serde_json::to_value(params)?;
1389 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1390 let _value = self
1391 .session
1392 .client()
1393 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
1394 .await?;
1395 Ok(())
1396 }
1397
1398 /// Emits a user-visible session log event.
1399 ///
1400 /// Wire method: `session.log`.
1401 ///
1402 /// # Parameters
1403 ///
1404 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
1405 ///
1406 /// # Returns
1407 ///
1408 /// Identifier of the session event that was emitted for the log message.
1409 ///
1410 /// <div class="warning">
1411 ///
1412 /// **Experimental.** This API is part of an experimental wire-protocol surface
1413 /// and may change or be removed in future SDK or CLI releases. Pin both the
1414 /// SDK and CLI versions if your code depends on it.
1415 ///
1416 /// </div>
1417 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
1418 let mut wire_params = serde_json::to_value(params)?;
1419 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1420 let _value = self
1421 .session
1422 .client()
1423 .call(rpc_methods::SESSION_LOG, Some(wire_params))
1424 .await?;
1425 Ok(serde_json::from_value(_value)?)
1426 }
1427}
1428
1429/// `session.agent.*` RPCs.
1430#[derive(Clone, Copy)]
1431pub struct SessionRpcAgent<'a> {
1432 pub(crate) session: &'a Session,
1433}
1434
1435impl<'a> SessionRpcAgent<'a> {
1436 /// Lists custom agents available to the session.
1437 ///
1438 /// Wire method: `session.agent.list`.
1439 ///
1440 /// # Returns
1441 ///
1442 /// Custom agents available to the session.
1443 ///
1444 /// <div class="warning">
1445 ///
1446 /// **Experimental.** This API is part of an experimental wire-protocol surface
1447 /// and may change or be removed in future SDK or CLI releases. Pin both the
1448 /// SDK and CLI versions if your code depends on it.
1449 ///
1450 /// </div>
1451 pub async fn list(&self) -> Result<AgentList, Error> {
1452 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1453 let _value = self
1454 .session
1455 .client()
1456 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
1457 .await?;
1458 Ok(serde_json::from_value(_value)?)
1459 }
1460
1461 /// Gets the currently selected custom agent for the session.
1462 ///
1463 /// Wire method: `session.agent.getCurrent`.
1464 ///
1465 /// # Returns
1466 ///
1467 /// The currently selected custom agent, or null when using the default agent.
1468 ///
1469 /// <div class="warning">
1470 ///
1471 /// **Experimental.** This API is part of an experimental wire-protocol surface
1472 /// and may change or be removed in future SDK or CLI releases. Pin both the
1473 /// SDK and CLI versions if your code depends on it.
1474 ///
1475 /// </div>
1476 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
1477 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1478 let _value = self
1479 .session
1480 .client()
1481 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
1482 .await?;
1483 Ok(serde_json::from_value(_value)?)
1484 }
1485
1486 /// Selects a custom agent for subsequent turns in the session.
1487 ///
1488 /// Wire method: `session.agent.select`.
1489 ///
1490 /// # Parameters
1491 ///
1492 /// * `params` - Name of the custom agent to select for subsequent turns.
1493 ///
1494 /// # Returns
1495 ///
1496 /// The newly selected custom agent.
1497 ///
1498 /// <div class="warning">
1499 ///
1500 /// **Experimental.** This API is part of an experimental wire-protocol surface
1501 /// and may change or be removed in future SDK or CLI releases. Pin both the
1502 /// SDK and CLI versions if your code depends on it.
1503 ///
1504 /// </div>
1505 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
1506 let mut wire_params = serde_json::to_value(params)?;
1507 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1508 let _value = self
1509 .session
1510 .client()
1511 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
1512 .await?;
1513 Ok(serde_json::from_value(_value)?)
1514 }
1515
1516 /// Clears the selected custom agent and returns the session to the default agent.
1517 ///
1518 /// Wire method: `session.agent.deselect`.
1519 ///
1520 /// <div class="warning">
1521 ///
1522 /// **Experimental.** This API is part of an experimental wire-protocol surface
1523 /// and may change or be removed in future SDK or CLI releases. Pin both the
1524 /// SDK and CLI versions if your code depends on it.
1525 ///
1526 /// </div>
1527 pub async fn deselect(&self) -> Result<(), Error> {
1528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1529 let _value = self
1530 .session
1531 .client()
1532 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
1533 .await?;
1534 Ok(())
1535 }
1536
1537 /// Reloads custom agent definitions and returns the refreshed list.
1538 ///
1539 /// Wire method: `session.agent.reload`.
1540 ///
1541 /// # Returns
1542 ///
1543 /// Custom agents available to the session after reloading definitions from disk.
1544 ///
1545 /// <div class="warning">
1546 ///
1547 /// **Experimental.** This API is part of an experimental wire-protocol surface
1548 /// and may change or be removed in future SDK or CLI releases. Pin both the
1549 /// SDK and CLI versions if your code depends on it.
1550 ///
1551 /// </div>
1552 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
1553 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1554 let _value = self
1555 .session
1556 .client()
1557 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
1558 .await?;
1559 Ok(serde_json::from_value(_value)?)
1560 }
1561}
1562
1563/// `session.auth.*` RPCs.
1564#[derive(Clone, Copy)]
1565pub struct SessionRpcAuth<'a> {
1566 pub(crate) session: &'a Session,
1567}
1568
1569impl<'a> SessionRpcAuth<'a> {
1570 /// Gets authentication status and account metadata for the session.
1571 ///
1572 /// Wire method: `session.auth.getStatus`.
1573 ///
1574 /// # Returns
1575 ///
1576 /// Authentication status and account metadata for the session.
1577 ///
1578 /// <div class="warning">
1579 ///
1580 /// **Experimental.** This API is part of an experimental wire-protocol surface
1581 /// and may change or be removed in future SDK or CLI releases. Pin both the
1582 /// SDK and CLI versions if your code depends on it.
1583 ///
1584 /// </div>
1585 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
1586 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1587 let _value = self
1588 .session
1589 .client()
1590 .call(rpc_methods::SESSION_AUTH_GETSTATUS, Some(wire_params))
1591 .await?;
1592 Ok(serde_json::from_value(_value)?)
1593 }
1594
1595 /// Updates the session's auth credentials used for outbound model and API requests.
1596 ///
1597 /// Wire method: `session.auth.setCredentials`.
1598 ///
1599 /// # Parameters
1600 ///
1601 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
1602 ///
1603 /// # Returns
1604 ///
1605 /// Indicates whether the credential update succeeded.
1606 ///
1607 /// <div class="warning">
1608 ///
1609 /// **Experimental.** This API is part of an experimental wire-protocol surface
1610 /// and may change or be removed in future SDK or CLI releases. Pin both the
1611 /// SDK and CLI versions if your code depends on it.
1612 ///
1613 /// </div>
1614 pub async fn set_credentials(
1615 &self,
1616 params: SessionSetCredentialsParams,
1617 ) -> Result<SessionSetCredentialsResult, Error> {
1618 let mut wire_params = serde_json::to_value(params)?;
1619 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1620 let _value = self
1621 .session
1622 .client()
1623 .call(rpc_methods::SESSION_AUTH_SETCREDENTIALS, Some(wire_params))
1624 .await?;
1625 Ok(serde_json::from_value(_value)?)
1626 }
1627}
1628
1629/// `session.commands.*` RPCs.
1630#[derive(Clone, Copy)]
1631pub struct SessionRpcCommands<'a> {
1632 pub(crate) session: &'a Session,
1633}
1634
1635impl<'a> SessionRpcCommands<'a> {
1636 /// Lists slash commands available in the session.
1637 ///
1638 /// Wire method: `session.commands.list`.
1639 ///
1640 /// # Returns
1641 ///
1642 /// Slash commands available in the session, after applying any include/exclude filters.
1643 ///
1644 /// <div class="warning">
1645 ///
1646 /// **Experimental.** This API is part of an experimental wire-protocol surface
1647 /// and may change or be removed in future SDK or CLI releases. Pin both the
1648 /// SDK and CLI versions if your code depends on it.
1649 ///
1650 /// </div>
1651 pub async fn list(&self) -> Result<CommandList, Error> {
1652 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1653 let _value = self
1654 .session
1655 .client()
1656 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
1657 .await?;
1658 Ok(serde_json::from_value(_value)?)
1659 }
1660
1661 /// Lists slash commands available in the session.
1662 ///
1663 /// Wire method: `session.commands.list`.
1664 ///
1665 /// # Parameters
1666 ///
1667 /// * `params` - Optional filters controlling which command sources to include in the listing.
1668 ///
1669 /// # Returns
1670 ///
1671 /// Slash commands available in the session, after applying any include/exclude filters.
1672 ///
1673 /// <div class="warning">
1674 ///
1675 /// **Experimental.** This API is part of an experimental wire-protocol surface
1676 /// and may change or be removed in future SDK or CLI releases. Pin both the
1677 /// SDK and CLI versions if your code depends on it.
1678 ///
1679 /// </div>
1680 pub async fn list_with_params(
1681 &self,
1682 params: CommandsListRequest,
1683 ) -> Result<CommandList, Error> {
1684 let mut wire_params = serde_json::to_value(params)?;
1685 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1686 let _value = self
1687 .session
1688 .client()
1689 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
1690 .await?;
1691 Ok(serde_json::from_value(_value)?)
1692 }
1693
1694 /// Invokes a slash command in the session.
1695 ///
1696 /// Wire method: `session.commands.invoke`.
1697 ///
1698 /// # Parameters
1699 ///
1700 /// * `params` - Slash command name and optional raw input string to invoke.
1701 ///
1702 /// # Returns
1703 ///
1704 /// Result of invoking the slash command (text output, prompt to send to the agent, or completion).
1705 ///
1706 /// <div class="warning">
1707 ///
1708 /// **Experimental.** This API is part of an experimental wire-protocol surface
1709 /// and may change or be removed in future SDK or CLI releases. Pin both the
1710 /// SDK and CLI versions if your code depends on it.
1711 ///
1712 /// </div>
1713 pub async fn invoke(
1714 &self,
1715 params: CommandsInvokeRequest,
1716 ) -> Result<SlashCommandInvocationResult, Error> {
1717 let mut wire_params = serde_json::to_value(params)?;
1718 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1719 let _value = self
1720 .session
1721 .client()
1722 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
1723 .await?;
1724 Ok(serde_json::from_value(_value)?)
1725 }
1726
1727 /// Reports completion of a pending client-handled slash command.
1728 ///
1729 /// Wire method: `session.commands.handlePendingCommand`.
1730 ///
1731 /// # Parameters
1732 ///
1733 /// * `params` - Pending command request ID and an optional error if the client handler failed.
1734 ///
1735 /// # Returns
1736 ///
1737 /// Indicates whether the pending client-handled command was completed successfully.
1738 ///
1739 /// <div class="warning">
1740 ///
1741 /// **Experimental.** This API is part of an experimental wire-protocol surface
1742 /// and may change or be removed in future SDK or CLI releases. Pin both the
1743 /// SDK and CLI versions if your code depends on it.
1744 ///
1745 /// </div>
1746 pub async fn handle_pending_command(
1747 &self,
1748 params: CommandsHandlePendingCommandRequest,
1749 ) -> Result<CommandsHandlePendingCommandResult, Error> {
1750 let mut wire_params = serde_json::to_value(params)?;
1751 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1752 let _value = self
1753 .session
1754 .client()
1755 .call(
1756 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
1757 Some(wire_params),
1758 )
1759 .await?;
1760 Ok(serde_json::from_value(_value)?)
1761 }
1762
1763 /// Executes a slash command synchronously and returns any error.
1764 ///
1765 /// Wire method: `session.commands.execute`.
1766 ///
1767 /// # Parameters
1768 ///
1769 /// * `params` - Slash command name and argument string to execute synchronously.
1770 ///
1771 /// # Returns
1772 ///
1773 /// Error message produced while executing the command, if any.
1774 ///
1775 /// <div class="warning">
1776 ///
1777 /// **Experimental.** This API is part of an experimental wire-protocol surface
1778 /// and may change or be removed in future SDK or CLI releases. Pin both the
1779 /// SDK and CLI versions if your code depends on it.
1780 ///
1781 /// </div>
1782 pub async fn execute(
1783 &self,
1784 params: ExecuteCommandParams,
1785 ) -> Result<ExecuteCommandResult, Error> {
1786 let mut wire_params = serde_json::to_value(params)?;
1787 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1788 let _value = self
1789 .session
1790 .client()
1791 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
1792 .await?;
1793 Ok(serde_json::from_value(_value)?)
1794 }
1795
1796 /// Enqueues a slash command for FIFO processing on the local session.
1797 ///
1798 /// Wire method: `session.commands.enqueue`.
1799 ///
1800 /// # Parameters
1801 ///
1802 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
1803 ///
1804 /// # Returns
1805 ///
1806 /// Indicates whether the command was accepted into the local execution queue.
1807 ///
1808 /// <div class="warning">
1809 ///
1810 /// **Experimental.** This API is part of an experimental wire-protocol surface
1811 /// and may change or be removed in future SDK or CLI releases. Pin both the
1812 /// SDK and CLI versions if your code depends on it.
1813 ///
1814 /// </div>
1815 pub async fn enqueue(
1816 &self,
1817 params: EnqueueCommandParams,
1818 ) -> Result<EnqueueCommandResult, Error> {
1819 let mut wire_params = serde_json::to_value(params)?;
1820 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1821 let _value = self
1822 .session
1823 .client()
1824 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
1825 .await?;
1826 Ok(serde_json::from_value(_value)?)
1827 }
1828
1829 /// Reports whether the host actually executed a queued command and whether to continue processing.
1830 ///
1831 /// Wire method: `session.commands.respondToQueuedCommand`.
1832 ///
1833 /// # Parameters
1834 ///
1835 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
1836 ///
1837 /// # Returns
1838 ///
1839 /// Indicates whether the queued-command response was matched to a pending request.
1840 ///
1841 /// <div class="warning">
1842 ///
1843 /// **Experimental.** This API is part of an experimental wire-protocol surface
1844 /// and may change or be removed in future SDK or CLI releases. Pin both the
1845 /// SDK and CLI versions if your code depends on it.
1846 ///
1847 /// </div>
1848 pub async fn respond_to_queued_command(
1849 &self,
1850 params: CommandsRespondToQueuedCommandRequest,
1851 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
1852 let mut wire_params = serde_json::to_value(params)?;
1853 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1854 let _value = self
1855 .session
1856 .client()
1857 .call(
1858 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
1859 Some(wire_params),
1860 )
1861 .await?;
1862 Ok(serde_json::from_value(_value)?)
1863 }
1864}
1865
1866/// `session.eventLog.*` RPCs.
1867#[derive(Clone, Copy)]
1868pub struct SessionRpcEventLog<'a> {
1869 pub(crate) session: &'a Session,
1870}
1871
1872impl<'a> SessionRpcEventLog<'a> {
1873 /// Reads a batch of session events from a cursor, optionally waiting for new events.
1874 ///
1875 /// Wire method: `session.eventLog.read`.
1876 ///
1877 /// # Parameters
1878 ///
1879 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
1880 ///
1881 /// # Returns
1882 ///
1883 /// Batch of session events returned by a read, with cursor and continuation metadata.
1884 ///
1885 /// <div class="warning">
1886 ///
1887 /// **Experimental.** This API is part of an experimental wire-protocol surface
1888 /// and may change or be removed in future SDK or CLI releases. Pin both the
1889 /// SDK and CLI versions if your code depends on it.
1890 ///
1891 /// </div>
1892 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
1893 let mut wire_params = serde_json::to_value(params)?;
1894 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1895 let _value = self
1896 .session
1897 .client()
1898 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
1899 .await?;
1900 Ok(serde_json::from_value(_value)?)
1901 }
1902
1903 /// Returns a snapshot of the current tail cursor without consuming events.
1904 ///
1905 /// Wire method: `session.eventLog.tail`.
1906 ///
1907 /// # Returns
1908 ///
1909 /// 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).
1910 ///
1911 /// <div class="warning">
1912 ///
1913 /// **Experimental.** This API is part of an experimental wire-protocol surface
1914 /// and may change or be removed in future SDK or CLI releases. Pin both the
1915 /// SDK and CLI versions if your code depends on it.
1916 ///
1917 /// </div>
1918 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
1919 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
1920 let _value = self
1921 .session
1922 .client()
1923 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
1924 .await?;
1925 Ok(serde_json::from_value(_value)?)
1926 }
1927
1928 /// Registers consumer interest in an event type for runtime gating purposes.
1929 ///
1930 /// Wire method: `session.eventLog.registerInterest`.
1931 ///
1932 /// # Parameters
1933 ///
1934 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
1935 ///
1936 /// # Returns
1937 ///
1938 /// Opaque handle representing an event-type interest registration.
1939 ///
1940 /// <div class="warning">
1941 ///
1942 /// **Experimental.** This API is part of an experimental wire-protocol surface
1943 /// and may change or be removed in future SDK or CLI releases. Pin both the
1944 /// SDK and CLI versions if your code depends on it.
1945 ///
1946 /// </div>
1947 pub async fn register_interest(
1948 &self,
1949 params: RegisterEventInterestParams,
1950 ) -> Result<RegisterEventInterestResult, Error> {
1951 let mut wire_params = serde_json::to_value(params)?;
1952 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1953 let _value = self
1954 .session
1955 .client()
1956 .call(
1957 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
1958 Some(wire_params),
1959 )
1960 .await?;
1961 Ok(serde_json::from_value(_value)?)
1962 }
1963
1964 /// Releases a consumer's previously-registered interest in an event type.
1965 ///
1966 /// Wire method: `session.eventLog.releaseInterest`.
1967 ///
1968 /// # Parameters
1969 ///
1970 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
1971 ///
1972 /// # Returns
1973 ///
1974 /// Indicates whether the operation succeeded.
1975 ///
1976 /// <div class="warning">
1977 ///
1978 /// **Experimental.** This API is part of an experimental wire-protocol surface
1979 /// and may change or be removed in future SDK or CLI releases. Pin both the
1980 /// SDK and CLI versions if your code depends on it.
1981 ///
1982 /// </div>
1983 pub async fn release_interest(
1984 &self,
1985 params: ReleaseEventInterestParams,
1986 ) -> Result<EventLogReleaseInterestResult, Error> {
1987 let mut wire_params = serde_json::to_value(params)?;
1988 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
1989 let _value = self
1990 .session
1991 .client()
1992 .call(
1993 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
1994 Some(wire_params),
1995 )
1996 .await?;
1997 Ok(serde_json::from_value(_value)?)
1998 }
1999}
2000
2001/// `session.extensions.*` RPCs.
2002#[derive(Clone, Copy)]
2003pub struct SessionRpcExtensions<'a> {
2004 pub(crate) session: &'a Session,
2005}
2006
2007impl<'a> SessionRpcExtensions<'a> {
2008 /// Lists extensions discovered for the session and their current status.
2009 ///
2010 /// Wire method: `session.extensions.list`.
2011 ///
2012 /// # Returns
2013 ///
2014 /// Extensions discovered for the session, with their current status.
2015 ///
2016 /// <div class="warning">
2017 ///
2018 /// **Experimental.** This API is part of an experimental wire-protocol surface
2019 /// and may change or be removed in future SDK or CLI releases. Pin both the
2020 /// SDK and CLI versions if your code depends on it.
2021 ///
2022 /// </div>
2023 pub async fn list(&self) -> Result<ExtensionList, Error> {
2024 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2025 let _value = self
2026 .session
2027 .client()
2028 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
2029 .await?;
2030 Ok(serde_json::from_value(_value)?)
2031 }
2032
2033 /// Enables an extension for the session.
2034 ///
2035 /// Wire method: `session.extensions.enable`.
2036 ///
2037 /// # Parameters
2038 ///
2039 /// * `params` - Source-qualified extension identifier to enable for the session.
2040 ///
2041 /// <div class="warning">
2042 ///
2043 /// **Experimental.** This API is part of an experimental wire-protocol surface
2044 /// and may change or be removed in future SDK or CLI releases. Pin both the
2045 /// SDK and CLI versions if your code depends on it.
2046 ///
2047 /// </div>
2048 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
2049 let mut wire_params = serde_json::to_value(params)?;
2050 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2051 let _value = self
2052 .session
2053 .client()
2054 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
2055 .await?;
2056 Ok(())
2057 }
2058
2059 /// Disables an extension for the session.
2060 ///
2061 /// Wire method: `session.extensions.disable`.
2062 ///
2063 /// # Parameters
2064 ///
2065 /// * `params` - Source-qualified extension identifier to disable for the session.
2066 ///
2067 /// <div class="warning">
2068 ///
2069 /// **Experimental.** This API is part of an experimental wire-protocol surface
2070 /// and may change or be removed in future SDK or CLI releases. Pin both the
2071 /// SDK and CLI versions if your code depends on it.
2072 ///
2073 /// </div>
2074 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
2075 let mut wire_params = serde_json::to_value(params)?;
2076 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2077 let _value = self
2078 .session
2079 .client()
2080 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
2081 .await?;
2082 Ok(())
2083 }
2084
2085 /// Reloads extension definitions and processes for the session.
2086 ///
2087 /// Wire method: `session.extensions.reload`.
2088 ///
2089 /// <div class="warning">
2090 ///
2091 /// **Experimental.** This API is part of an experimental wire-protocol surface
2092 /// and may change or be removed in future SDK or CLI releases. Pin both the
2093 /// SDK and CLI versions if your code depends on it.
2094 ///
2095 /// </div>
2096 pub async fn reload(&self) -> Result<(), Error> {
2097 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2098 let _value = self
2099 .session
2100 .client()
2101 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
2102 .await?;
2103 Ok(())
2104 }
2105}
2106
2107/// `session.fleet.*` RPCs.
2108#[derive(Clone, Copy)]
2109pub struct SessionRpcFleet<'a> {
2110 pub(crate) session: &'a Session,
2111}
2112
2113impl<'a> SessionRpcFleet<'a> {
2114 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
2115 ///
2116 /// Wire method: `session.fleet.start`.
2117 ///
2118 /// # Parameters
2119 ///
2120 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
2121 ///
2122 /// # Returns
2123 ///
2124 /// Indicates whether fleet mode was successfully activated.
2125 ///
2126 /// <div class="warning">
2127 ///
2128 /// **Experimental.** This API is part of an experimental wire-protocol surface
2129 /// and may change or be removed in future SDK or CLI releases. Pin both the
2130 /// SDK and CLI versions if your code depends on it.
2131 ///
2132 /// </div>
2133 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
2134 let mut wire_params = serde_json::to_value(params)?;
2135 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2136 let _value = self
2137 .session
2138 .client()
2139 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
2140 .await?;
2141 Ok(serde_json::from_value(_value)?)
2142 }
2143}
2144
2145/// `session.history.*` RPCs.
2146#[derive(Clone, Copy)]
2147pub struct SessionRpcHistory<'a> {
2148 pub(crate) session: &'a Session,
2149}
2150
2151impl<'a> SessionRpcHistory<'a> {
2152 /// Compacts the session history to reduce context usage.
2153 ///
2154 /// Wire method: `session.history.compact`.
2155 ///
2156 /// # Returns
2157 ///
2158 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
2159 ///
2160 /// <div class="warning">
2161 ///
2162 /// **Experimental.** This API is part of an experimental wire-protocol surface
2163 /// and may change or be removed in future SDK or CLI releases. Pin both the
2164 /// SDK and CLI versions if your code depends on it.
2165 ///
2166 /// </div>
2167 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
2168 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2169 let _value = self
2170 .session
2171 .client()
2172 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
2173 .await?;
2174 Ok(serde_json::from_value(_value)?)
2175 }
2176
2177 /// Truncates persisted session history to a specific event.
2178 ///
2179 /// Wire method: `session.history.truncate`.
2180 ///
2181 /// # Parameters
2182 ///
2183 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
2184 ///
2185 /// # Returns
2186 ///
2187 /// Number of events that were removed by the truncation.
2188 ///
2189 /// <div class="warning">
2190 ///
2191 /// **Experimental.** This API is part of an experimental wire-protocol surface
2192 /// and may change or be removed in future SDK or CLI releases. Pin both the
2193 /// SDK and CLI versions if your code depends on it.
2194 ///
2195 /// </div>
2196 pub async fn truncate(
2197 &self,
2198 params: HistoryTruncateRequest,
2199 ) -> Result<HistoryTruncateResult, Error> {
2200 let mut wire_params = serde_json::to_value(params)?;
2201 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2202 let _value = self
2203 .session
2204 .client()
2205 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
2206 .await?;
2207 Ok(serde_json::from_value(_value)?)
2208 }
2209
2210 /// Cancels any in-progress background compaction on a local session.
2211 ///
2212 /// Wire method: `session.history.cancelBackgroundCompaction`.
2213 ///
2214 /// # Returns
2215 ///
2216 /// Indicates whether an in-progress background compaction was cancelled.
2217 ///
2218 /// <div class="warning">
2219 ///
2220 /// **Experimental.** This API is part of an experimental wire-protocol surface
2221 /// and may change or be removed in future SDK or CLI releases. Pin both the
2222 /// SDK and CLI versions if your code depends on it.
2223 ///
2224 /// </div>
2225 pub async fn cancel_background_compaction(
2226 &self,
2227 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
2228 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2229 let _value = self
2230 .session
2231 .client()
2232 .call(
2233 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
2234 Some(wire_params),
2235 )
2236 .await?;
2237 Ok(serde_json::from_value(_value)?)
2238 }
2239
2240 /// Aborts any in-progress manual compaction on a local session.
2241 ///
2242 /// Wire method: `session.history.abortManualCompaction`.
2243 ///
2244 /// # Returns
2245 ///
2246 /// Indicates whether an in-progress manual compaction was aborted.
2247 ///
2248 /// <div class="warning">
2249 ///
2250 /// **Experimental.** This API is part of an experimental wire-protocol surface
2251 /// and may change or be removed in future SDK or CLI releases. Pin both the
2252 /// SDK and CLI versions if your code depends on it.
2253 ///
2254 /// </div>
2255 pub async fn abort_manual_compaction(
2256 &self,
2257 ) -> Result<HistoryAbortManualCompactionResult, Error> {
2258 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2259 let _value = self
2260 .session
2261 .client()
2262 .call(
2263 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
2264 Some(wire_params),
2265 )
2266 .await?;
2267 Ok(serde_json::from_value(_value)?)
2268 }
2269
2270 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
2271 ///
2272 /// Wire method: `session.history.summarizeForHandoff`.
2273 ///
2274 /// # Returns
2275 ///
2276 /// Markdown summary of the conversation context (empty when not available).
2277 ///
2278 /// <div class="warning">
2279 ///
2280 /// **Experimental.** This API is part of an experimental wire-protocol surface
2281 /// and may change or be removed in future SDK or CLI releases. Pin both the
2282 /// SDK and CLI versions if your code depends on it.
2283 ///
2284 /// </div>
2285 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
2286 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2287 let _value = self
2288 .session
2289 .client()
2290 .call(
2291 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
2292 Some(wire_params),
2293 )
2294 .await?;
2295 Ok(serde_json::from_value(_value)?)
2296 }
2297}
2298
2299/// `session.instructions.*` RPCs.
2300#[derive(Clone, Copy)]
2301pub struct SessionRpcInstructions<'a> {
2302 pub(crate) session: &'a Session,
2303}
2304
2305impl<'a> SessionRpcInstructions<'a> {
2306 /// Gets instruction sources loaded for the session.
2307 ///
2308 /// Wire method: `session.instructions.getSources`.
2309 ///
2310 /// # Returns
2311 ///
2312 /// Instruction sources loaded for the session, in merge order.
2313 ///
2314 /// <div class="warning">
2315 ///
2316 /// **Experimental.** This API is part of an experimental wire-protocol surface
2317 /// and may change or be removed in future SDK or CLI releases. Pin both the
2318 /// SDK and CLI versions if your code depends on it.
2319 ///
2320 /// </div>
2321 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
2322 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2323 let _value = self
2324 .session
2325 .client()
2326 .call(
2327 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
2328 Some(wire_params),
2329 )
2330 .await?;
2331 Ok(serde_json::from_value(_value)?)
2332 }
2333}
2334
2335/// `session.lsp.*` RPCs.
2336#[derive(Clone, Copy)]
2337pub struct SessionRpcLsp<'a> {
2338 pub(crate) session: &'a Session,
2339}
2340
2341impl<'a> SessionRpcLsp<'a> {
2342 /// Loads the merged LSP configuration set for the session's working directory.
2343 ///
2344 /// Wire method: `session.lsp.initialize`.
2345 ///
2346 /// # Parameters
2347 ///
2348 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
2349 ///
2350 /// <div class="warning">
2351 ///
2352 /// **Experimental.** This API is part of an experimental wire-protocol surface
2353 /// and may change or be removed in future SDK or CLI releases. Pin both the
2354 /// SDK and CLI versions if your code depends on it.
2355 ///
2356 /// </div>
2357 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
2358 let mut wire_params = serde_json::to_value(params)?;
2359 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2360 let _value = self
2361 .session
2362 .client()
2363 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
2364 .await?;
2365 Ok(())
2366 }
2367}
2368
2369/// `session.mcp.*` RPCs.
2370#[derive(Clone, Copy)]
2371pub struct SessionRpcMcp<'a> {
2372 pub(crate) session: &'a Session,
2373}
2374
2375impl<'a> SessionRpcMcp<'a> {
2376 /// `session.mcp.oauth.*` sub-namespace.
2377 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
2378 SessionRpcMcpOauth {
2379 session: self.session,
2380 }
2381 }
2382
2383 /// Lists MCP servers configured for the session and their connection status.
2384 ///
2385 /// Wire method: `session.mcp.list`.
2386 ///
2387 /// # Returns
2388 ///
2389 /// MCP servers configured for the session, with their connection status.
2390 ///
2391 /// <div class="warning">
2392 ///
2393 /// **Experimental.** This API is part of an experimental wire-protocol surface
2394 /// and may change or be removed in future SDK or CLI releases. Pin both the
2395 /// SDK and CLI versions if your code depends on it.
2396 ///
2397 /// </div>
2398 pub async fn list(&self) -> Result<McpServerList, Error> {
2399 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2400 let _value = self
2401 .session
2402 .client()
2403 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
2404 .await?;
2405 Ok(serde_json::from_value(_value)?)
2406 }
2407
2408 /// Enables an MCP server for the session.
2409 ///
2410 /// Wire method: `session.mcp.enable`.
2411 ///
2412 /// # Parameters
2413 ///
2414 /// * `params` - Name of the MCP server to enable for the session.
2415 ///
2416 /// <div class="warning">
2417 ///
2418 /// **Experimental.** This API is part of an experimental wire-protocol surface
2419 /// and may change or be removed in future SDK or CLI releases. Pin both the
2420 /// SDK and CLI versions if your code depends on it.
2421 ///
2422 /// </div>
2423 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
2424 let mut wire_params = serde_json::to_value(params)?;
2425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2426 let _value = self
2427 .session
2428 .client()
2429 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
2430 .await?;
2431 Ok(())
2432 }
2433
2434 /// Disables an MCP server for the session.
2435 ///
2436 /// Wire method: `session.mcp.disable`.
2437 ///
2438 /// # Parameters
2439 ///
2440 /// * `params` - Name of the MCP server to disable for the session.
2441 ///
2442 /// <div class="warning">
2443 ///
2444 /// **Experimental.** This API is part of an experimental wire-protocol surface
2445 /// and may change or be removed in future SDK or CLI releases. Pin both the
2446 /// SDK and CLI versions if your code depends on it.
2447 ///
2448 /// </div>
2449 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
2450 let mut wire_params = serde_json::to_value(params)?;
2451 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2452 let _value = self
2453 .session
2454 .client()
2455 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
2456 .await?;
2457 Ok(())
2458 }
2459
2460 /// Reloads MCP server connections for the session.
2461 ///
2462 /// Wire method: `session.mcp.reload`.
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 reload(&self) -> Result<(), Error> {
2472 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2473 let _value = self
2474 .session
2475 .client()
2476 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
2477 .await?;
2478 Ok(())
2479 }
2480
2481 /// Runs an MCP sampling inference on behalf of an MCP server.
2482 ///
2483 /// Wire method: `session.mcp.executeSampling`.
2484 ///
2485 /// # Parameters
2486 ///
2487 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
2488 ///
2489 /// # Returns
2490 ///
2491 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
2492 ///
2493 /// <div class="warning">
2494 ///
2495 /// **Experimental.** This API is part of an experimental wire-protocol surface
2496 /// and may change or be removed in future SDK or CLI releases. Pin both the
2497 /// SDK and CLI versions if your code depends on it.
2498 ///
2499 /// </div>
2500 pub async fn execute_sampling(
2501 &self,
2502 params: McpExecuteSamplingParams,
2503 ) -> Result<McpSamplingExecutionResult, Error> {
2504 let mut wire_params = serde_json::to_value(params)?;
2505 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2506 let _value = self
2507 .session
2508 .client()
2509 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
2510 .await?;
2511 Ok(serde_json::from_value(_value)?)
2512 }
2513
2514 /// Cancels an in-flight MCP sampling execution by request ID.
2515 ///
2516 /// Wire method: `session.mcp.cancelSamplingExecution`.
2517 ///
2518 /// # Parameters
2519 ///
2520 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
2521 ///
2522 /// # Returns
2523 ///
2524 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
2525 ///
2526 /// <div class="warning">
2527 ///
2528 /// **Experimental.** This API is part of an experimental wire-protocol surface
2529 /// and may change or be removed in future SDK or CLI releases. Pin both the
2530 /// SDK and CLI versions if your code depends on it.
2531 ///
2532 /// </div>
2533 pub async fn cancel_sampling_execution(
2534 &self,
2535 params: McpCancelSamplingExecutionParams,
2536 ) -> Result<McpCancelSamplingExecutionResult, Error> {
2537 let mut wire_params = serde_json::to_value(params)?;
2538 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2539 let _value = self
2540 .session
2541 .client()
2542 .call(
2543 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
2544 Some(wire_params),
2545 )
2546 .await?;
2547 Ok(serde_json::from_value(_value)?)
2548 }
2549
2550 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
2551 ///
2552 /// Wire method: `session.mcp.setEnvValueMode`.
2553 ///
2554 /// # Parameters
2555 ///
2556 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
2557 ///
2558 /// # Returns
2559 ///
2560 /// Env-value mode recorded on the session after the update.
2561 ///
2562 /// <div class="warning">
2563 ///
2564 /// **Experimental.** This API is part of an experimental wire-protocol surface
2565 /// and may change or be removed in future SDK or CLI releases. Pin both the
2566 /// SDK and CLI versions if your code depends on it.
2567 ///
2568 /// </div>
2569 pub async fn set_env_value_mode(
2570 &self,
2571 params: McpSetEnvValueModeParams,
2572 ) -> Result<McpSetEnvValueModeResult, Error> {
2573 let mut wire_params = serde_json::to_value(params)?;
2574 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2575 let _value = self
2576 .session
2577 .client()
2578 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
2579 .await?;
2580 Ok(serde_json::from_value(_value)?)
2581 }
2582
2583 /// Removes the auto-managed `github` MCP server when present.
2584 ///
2585 /// Wire method: `session.mcp.removeGitHub`.
2586 ///
2587 /// # Returns
2588 ///
2589 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
2590 ///
2591 /// <div class="warning">
2592 ///
2593 /// **Experimental.** This API is part of an experimental wire-protocol surface
2594 /// and may change or be removed in future SDK or CLI releases. Pin both the
2595 /// SDK and CLI versions if your code depends on it.
2596 ///
2597 /// </div>
2598 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
2599 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2600 let _value = self
2601 .session
2602 .client()
2603 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
2604 .await?;
2605 Ok(serde_json::from_value(_value)?)
2606 }
2607}
2608
2609/// `session.mcp.oauth.*` RPCs.
2610#[derive(Clone, Copy)]
2611pub struct SessionRpcMcpOauth<'a> {
2612 pub(crate) session: &'a Session,
2613}
2614
2615impl<'a> SessionRpcMcpOauth<'a> {
2616 /// Starts OAuth authentication for a remote MCP server.
2617 ///
2618 /// Wire method: `session.mcp.oauth.login`.
2619 ///
2620 /// # Parameters
2621 ///
2622 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, and the callback success-page copy.
2623 ///
2624 /// # Returns
2625 ///
2626 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
2627 ///
2628 /// <div class="warning">
2629 ///
2630 /// **Experimental.** This API is part of an experimental wire-protocol surface
2631 /// and may change or be removed in future SDK or CLI releases. Pin both the
2632 /// SDK and CLI versions if your code depends on it.
2633 ///
2634 /// </div>
2635 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
2636 let mut wire_params = serde_json::to_value(params)?;
2637 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2638 let _value = self
2639 .session
2640 .client()
2641 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
2642 .await?;
2643 Ok(serde_json::from_value(_value)?)
2644 }
2645}
2646
2647/// `session.metadata.*` RPCs.
2648#[derive(Clone, Copy)]
2649pub struct SessionRpcMetadata<'a> {
2650 pub(crate) session: &'a Session,
2651}
2652
2653impl<'a> SessionRpcMetadata<'a> {
2654 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
2655 ///
2656 /// Wire method: `session.metadata.snapshot`.
2657 ///
2658 /// # Returns
2659 ///
2660 /// Point-in-time snapshot of slow-changing session identifier and state fields
2661 ///
2662 /// <div class="warning">
2663 ///
2664 /// **Experimental.** This API is part of an experimental wire-protocol surface
2665 /// and may change or be removed in future SDK or CLI releases. Pin both the
2666 /// SDK and CLI versions if your code depends on it.
2667 ///
2668 /// </div>
2669 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
2670 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2671 let _value = self
2672 .session
2673 .client()
2674 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
2675 .await?;
2676 Ok(serde_json::from_value(_value)?)
2677 }
2678
2679 /// Reports whether the local session is currently processing user/agent messages.
2680 ///
2681 /// Wire method: `session.metadata.isProcessing`.
2682 ///
2683 /// # Returns
2684 ///
2685 /// Indicates whether the local session is currently processing a turn or background continuation.
2686 ///
2687 /// <div class="warning">
2688 ///
2689 /// **Experimental.** This API is part of an experimental wire-protocol surface
2690 /// and may change or be removed in future SDK or CLI releases. Pin both the
2691 /// SDK and CLI versions if your code depends on it.
2692 ///
2693 /// </div>
2694 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
2695 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2696 let _value = self
2697 .session
2698 .client()
2699 .call(
2700 rpc_methods::SESSION_METADATA_ISPROCESSING,
2701 Some(wire_params),
2702 )
2703 .await?;
2704 Ok(serde_json::from_value(_value)?)
2705 }
2706
2707 /// Returns the token breakdown for the session's current context window for a given model.
2708 ///
2709 /// Wire method: `session.metadata.contextInfo`.
2710 ///
2711 /// # Parameters
2712 ///
2713 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
2714 ///
2715 /// # Returns
2716 ///
2717 /// Token breakdown for the session's current context window, or null if uninitialized.
2718 ///
2719 /// <div class="warning">
2720 ///
2721 /// **Experimental.** This API is part of an experimental wire-protocol surface
2722 /// and may change or be removed in future SDK or CLI releases. Pin both the
2723 /// SDK and CLI versions if your code depends on it.
2724 ///
2725 /// </div>
2726 pub async fn context_info(
2727 &self,
2728 params: MetadataContextInfoRequest,
2729 ) -> Result<MetadataContextInfoResult, Error> {
2730 let mut wire_params = serde_json::to_value(params)?;
2731 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2732 let _value = self
2733 .session
2734 .client()
2735 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
2736 .await?;
2737 Ok(serde_json::from_value(_value)?)
2738 }
2739
2740 /// Records a working-directory/git context change and emits a `session.context_changed` event.
2741 ///
2742 /// Wire method: `session.metadata.recordContextChange`.
2743 ///
2744 /// # Parameters
2745 ///
2746 /// * `params` - Updated working-directory/git context to record on the session.
2747 ///
2748 /// # Returns
2749 ///
2750 /// 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).
2751 ///
2752 /// <div class="warning">
2753 ///
2754 /// **Experimental.** This API is part of an experimental wire-protocol surface
2755 /// and may change or be removed in future SDK or CLI releases. Pin both the
2756 /// SDK and CLI versions if your code depends on it.
2757 ///
2758 /// </div>
2759 pub async fn record_context_change(
2760 &self,
2761 params: MetadataRecordContextChangeRequest,
2762 ) -> Result<MetadataRecordContextChangeResult, Error> {
2763 let mut wire_params = serde_json::to_value(params)?;
2764 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2765 let _value = self
2766 .session
2767 .client()
2768 .call(
2769 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
2770 Some(wire_params),
2771 )
2772 .await?;
2773 Ok(serde_json::from_value(_value)?)
2774 }
2775
2776 /// Updates the session's recorded working directory.
2777 ///
2778 /// Wire method: `session.metadata.setWorkingDirectory`.
2779 ///
2780 /// # Parameters
2781 ///
2782 /// * `params` - Absolute path to set as the session's new working directory.
2783 ///
2784 /// # Returns
2785 ///
2786 /// Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for `process.chdir` and any related side-effects (file index, etc.); this method only updates the session's own recorded path.
2787 ///
2788 /// <div class="warning">
2789 ///
2790 /// **Experimental.** This API is part of an experimental wire-protocol surface
2791 /// and may change or be removed in future SDK or CLI releases. Pin both the
2792 /// SDK and CLI versions if your code depends on it.
2793 ///
2794 /// </div>
2795 pub async fn set_working_directory(
2796 &self,
2797 params: MetadataSetWorkingDirectoryRequest,
2798 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
2799 let mut wire_params = serde_json::to_value(params)?;
2800 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2801 let _value = self
2802 .session
2803 .client()
2804 .call(
2805 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
2806 Some(wire_params),
2807 )
2808 .await?;
2809 Ok(serde_json::from_value(_value)?)
2810 }
2811
2812 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
2813 ///
2814 /// Wire method: `session.metadata.recomputeContextTokens`.
2815 ///
2816 /// # Parameters
2817 ///
2818 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
2819 ///
2820 /// # Returns
2821 ///
2822 /// 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.
2823 ///
2824 /// <div class="warning">
2825 ///
2826 /// **Experimental.** This API is part of an experimental wire-protocol surface
2827 /// and may change or be removed in future SDK or CLI releases. Pin both the
2828 /// SDK and CLI versions if your code depends on it.
2829 ///
2830 /// </div>
2831 pub async fn recompute_context_tokens(
2832 &self,
2833 params: MetadataRecomputeContextTokensRequest,
2834 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
2835 let mut wire_params = serde_json::to_value(params)?;
2836 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2837 let _value = self
2838 .session
2839 .client()
2840 .call(
2841 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
2842 Some(wire_params),
2843 )
2844 .await?;
2845 Ok(serde_json::from_value(_value)?)
2846 }
2847}
2848
2849/// `session.mode.*` RPCs.
2850#[derive(Clone, Copy)]
2851pub struct SessionRpcMode<'a> {
2852 pub(crate) session: &'a Session,
2853}
2854
2855impl<'a> SessionRpcMode<'a> {
2856 /// Gets the current agent interaction mode.
2857 ///
2858 /// Wire method: `session.mode.get`.
2859 ///
2860 /// # Returns
2861 ///
2862 /// The session mode the agent is operating in
2863 ///
2864 /// <div class="warning">
2865 ///
2866 /// **Experimental.** This API is part of an experimental wire-protocol surface
2867 /// and may change or be removed in future SDK or CLI releases. Pin both the
2868 /// SDK and CLI versions if your code depends on it.
2869 ///
2870 /// </div>
2871 pub async fn get(&self) -> Result<SessionMode, Error> {
2872 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2873 let _value = self
2874 .session
2875 .client()
2876 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
2877 .await?;
2878 Ok(serde_json::from_value(_value)?)
2879 }
2880
2881 /// Sets the current agent interaction mode.
2882 ///
2883 /// Wire method: `session.mode.set`.
2884 ///
2885 /// # Parameters
2886 ///
2887 /// * `params` - Agent interaction mode to apply to the session.
2888 ///
2889 /// <div class="warning">
2890 ///
2891 /// **Experimental.** This API is part of an experimental wire-protocol surface
2892 /// and may change or be removed in future SDK or CLI releases. Pin both the
2893 /// SDK and CLI versions if your code depends on it.
2894 ///
2895 /// </div>
2896 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
2897 let mut wire_params = serde_json::to_value(params)?;
2898 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2899 let _value = self
2900 .session
2901 .client()
2902 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
2903 .await?;
2904 Ok(())
2905 }
2906}
2907
2908/// `session.model.*` RPCs.
2909#[derive(Clone, Copy)]
2910pub struct SessionRpcModel<'a> {
2911 pub(crate) session: &'a Session,
2912}
2913
2914impl<'a> SessionRpcModel<'a> {
2915 /// Gets the currently selected model for the session.
2916 ///
2917 /// Wire method: `session.model.getCurrent`.
2918 ///
2919 /// # Returns
2920 ///
2921 /// The currently selected model and reasoning effort for the session.
2922 ///
2923 /// <div class="warning">
2924 ///
2925 /// **Experimental.** This API is part of an experimental wire-protocol surface
2926 /// and may change or be removed in future SDK or CLI releases. Pin both the
2927 /// SDK and CLI versions if your code depends on it.
2928 ///
2929 /// </div>
2930 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
2931 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2932 let _value = self
2933 .session
2934 .client()
2935 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
2936 .await?;
2937 Ok(serde_json::from_value(_value)?)
2938 }
2939
2940 /// Switches the session to a model and optional reasoning configuration.
2941 ///
2942 /// Wire method: `session.model.switchTo`.
2943 ///
2944 /// # Parameters
2945 ///
2946 /// * `params` - Target model identifier and optional reasoning effort, summary, and capability overrides.
2947 ///
2948 /// # Returns
2949 ///
2950 /// The model identifier active on the session after the switch.
2951 ///
2952 /// <div class="warning">
2953 ///
2954 /// **Experimental.** This API is part of an experimental wire-protocol surface
2955 /// and may change or be removed in future SDK or CLI releases. Pin both the
2956 /// SDK and CLI versions if your code depends on it.
2957 ///
2958 /// </div>
2959 pub async fn switch_to(
2960 &self,
2961 params: ModelSwitchToRequest,
2962 ) -> Result<ModelSwitchToResult, Error> {
2963 let mut wire_params = serde_json::to_value(params)?;
2964 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2965 let _value = self
2966 .session
2967 .client()
2968 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
2969 .await?;
2970 Ok(serde_json::from_value(_value)?)
2971 }
2972
2973 /// Updates the session's reasoning effort without changing the selected model.
2974 ///
2975 /// Wire method: `session.model.setReasoningEffort`.
2976 ///
2977 /// # Parameters
2978 ///
2979 /// * `params` - Reasoning effort level to apply to the currently selected model.
2980 ///
2981 /// # Returns
2982 ///
2983 /// 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.
2984 ///
2985 /// <div class="warning">
2986 ///
2987 /// **Experimental.** This API is part of an experimental wire-protocol surface
2988 /// and may change or be removed in future SDK or CLI releases. Pin both the
2989 /// SDK and CLI versions if your code depends on it.
2990 ///
2991 /// </div>
2992 pub async fn set_reasoning_effort(
2993 &self,
2994 params: ModelSetReasoningEffortRequest,
2995 ) -> Result<ModelSetReasoningEffortResult, Error> {
2996 let mut wire_params = serde_json::to_value(params)?;
2997 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2998 let _value = self
2999 .session
3000 .client()
3001 .call(
3002 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
3003 Some(wire_params),
3004 )
3005 .await?;
3006 Ok(serde_json::from_value(_value)?)
3007 }
3008}
3009
3010/// `session.name.*` RPCs.
3011#[derive(Clone, Copy)]
3012pub struct SessionRpcName<'a> {
3013 pub(crate) session: &'a Session,
3014}
3015
3016impl<'a> SessionRpcName<'a> {
3017 /// Gets the session's friendly name.
3018 ///
3019 /// Wire method: `session.name.get`.
3020 ///
3021 /// # Returns
3022 ///
3023 /// The session's friendly name, or null when not yet set.
3024 ///
3025 /// <div class="warning">
3026 ///
3027 /// **Experimental.** This API is part of an experimental wire-protocol surface
3028 /// and may change or be removed in future SDK or CLI releases. Pin both the
3029 /// SDK and CLI versions if your code depends on it.
3030 ///
3031 /// </div>
3032 pub async fn get(&self) -> Result<NameGetResult, Error> {
3033 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3034 let _value = self
3035 .session
3036 .client()
3037 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
3038 .await?;
3039 Ok(serde_json::from_value(_value)?)
3040 }
3041
3042 /// Sets the session's friendly name.
3043 ///
3044 /// Wire method: `session.name.set`.
3045 ///
3046 /// # Parameters
3047 ///
3048 /// * `params` - New friendly name to apply to the session.
3049 ///
3050 /// <div class="warning">
3051 ///
3052 /// **Experimental.** This API is part of an experimental wire-protocol surface
3053 /// and may change or be removed in future SDK or CLI releases. Pin both the
3054 /// SDK and CLI versions if your code depends on it.
3055 ///
3056 /// </div>
3057 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
3058 let mut wire_params = serde_json::to_value(params)?;
3059 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3060 let _value = self
3061 .session
3062 .client()
3063 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
3064 .await?;
3065 Ok(())
3066 }
3067
3068 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
3069 ///
3070 /// Wire method: `session.name.setAuto`.
3071 ///
3072 /// # Parameters
3073 ///
3074 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
3075 ///
3076 /// # Returns
3077 ///
3078 /// Indicates whether the auto-generated summary was applied as the session's name.
3079 ///
3080 /// <div class="warning">
3081 ///
3082 /// **Experimental.** This API is part of an experimental wire-protocol surface
3083 /// and may change or be removed in future SDK or CLI releases. Pin both the
3084 /// SDK and CLI versions if your code depends on it.
3085 ///
3086 /// </div>
3087 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
3088 let mut wire_params = serde_json::to_value(params)?;
3089 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3090 let _value = self
3091 .session
3092 .client()
3093 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
3094 .await?;
3095 Ok(serde_json::from_value(_value)?)
3096 }
3097}
3098
3099/// `session.options.*` RPCs.
3100#[derive(Clone, Copy)]
3101pub struct SessionRpcOptions<'a> {
3102 pub(crate) session: &'a Session,
3103}
3104
3105impl<'a> SessionRpcOptions<'a> {
3106 /// Patches the genuinely-mutable subset of session options.
3107 ///
3108 /// Wire method: `session.options.update`.
3109 ///
3110 /// # Parameters
3111 ///
3112 /// * `params` - Patch of mutable session options to apply to the running session.
3113 ///
3114 /// # Returns
3115 ///
3116 /// Indicates whether the session options patch was applied successfully.
3117 ///
3118 /// <div class="warning">
3119 ///
3120 /// **Experimental.** This API is part of an experimental wire-protocol surface
3121 /// and may change or be removed in future SDK or CLI releases. Pin both the
3122 /// SDK and CLI versions if your code depends on it.
3123 ///
3124 /// </div>
3125 pub async fn update(
3126 &self,
3127 params: SessionUpdateOptionsParams,
3128 ) -> Result<SessionUpdateOptionsResult, Error> {
3129 let mut wire_params = serde_json::to_value(params)?;
3130 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3131 let _value = self
3132 .session
3133 .client()
3134 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
3135 .await?;
3136 Ok(serde_json::from_value(_value)?)
3137 }
3138}
3139
3140/// `session.permissions.*` RPCs.
3141#[derive(Clone, Copy)]
3142pub struct SessionRpcPermissions<'a> {
3143 pub(crate) session: &'a Session,
3144}
3145
3146impl<'a> SessionRpcPermissions<'a> {
3147 /// `session.permissions.folderTrust.*` sub-namespace.
3148 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
3149 SessionRpcPermissionsFolderTrust {
3150 session: self.session,
3151 }
3152 }
3153
3154 /// `session.permissions.locations.*` sub-namespace.
3155 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
3156 SessionRpcPermissionsLocations {
3157 session: self.session,
3158 }
3159 }
3160
3161 /// `session.permissions.paths.*` sub-namespace.
3162 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
3163 SessionRpcPermissionsPaths {
3164 session: self.session,
3165 }
3166 }
3167
3168 /// `session.permissions.urls.*` sub-namespace.
3169 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
3170 SessionRpcPermissionsUrls {
3171 session: self.session,
3172 }
3173 }
3174
3175 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
3176 ///
3177 /// Wire method: `session.permissions.configure`.
3178 ///
3179 /// # Parameters
3180 ///
3181 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
3182 ///
3183 /// # Returns
3184 ///
3185 /// Indicates whether the operation succeeded.
3186 ///
3187 /// <div class="warning">
3188 ///
3189 /// **Experimental.** This API is part of an experimental wire-protocol surface
3190 /// and may change or be removed in future SDK or CLI releases. Pin both the
3191 /// SDK and CLI versions if your code depends on it.
3192 ///
3193 /// </div>
3194 pub async fn configure(
3195 &self,
3196 params: PermissionsConfigureParams,
3197 ) -> Result<PermissionsConfigureResult, Error> {
3198 let mut wire_params = serde_json::to_value(params)?;
3199 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3200 let _value = self
3201 .session
3202 .client()
3203 .call(
3204 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
3205 Some(wire_params),
3206 )
3207 .await?;
3208 Ok(serde_json::from_value(_value)?)
3209 }
3210
3211 /// Provides a decision for a pending tool permission request.
3212 ///
3213 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
3214 ///
3215 /// # Parameters
3216 ///
3217 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
3218 ///
3219 /// # Returns
3220 ///
3221 /// Indicates whether the permission decision was applied; false when the request was already resolved.
3222 ///
3223 /// <div class="warning">
3224 ///
3225 /// **Experimental.** This API is part of an experimental wire-protocol surface
3226 /// and may change or be removed in future SDK or CLI releases. Pin both the
3227 /// SDK and CLI versions if your code depends on it.
3228 ///
3229 /// </div>
3230 pub async fn handle_pending_permission_request(
3231 &self,
3232 params: PermissionDecisionRequest,
3233 ) -> Result<PermissionRequestResult, Error> {
3234 let mut wire_params = serde_json::to_value(params)?;
3235 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3236 let _value = self
3237 .session
3238 .client()
3239 .call(
3240 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
3241 Some(wire_params),
3242 )
3243 .await?;
3244 Ok(serde_json::from_value(_value)?)
3245 }
3246
3247 /// Reconstructs the set of pending tool permission requests from the session's event history.
3248 ///
3249 /// Wire method: `session.permissions.pendingRequests`.
3250 ///
3251 /// # Returns
3252 ///
3253 /// List of pending permission requests reconstructed from event history.
3254 ///
3255 /// <div class="warning">
3256 ///
3257 /// **Experimental.** This API is part of an experimental wire-protocol surface
3258 /// and may change or be removed in future SDK or CLI releases. Pin both the
3259 /// SDK and CLI versions if your code depends on it.
3260 ///
3261 /// </div>
3262 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
3263 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3264 let _value = self
3265 .session
3266 .client()
3267 .call(
3268 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
3269 Some(wire_params),
3270 )
3271 .await?;
3272 Ok(serde_json::from_value(_value)?)
3273 }
3274
3275 /// Enables or disables automatic approval of tool permission requests for the session.
3276 ///
3277 /// Wire method: `session.permissions.setApproveAll`.
3278 ///
3279 /// # Parameters
3280 ///
3281 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
3282 ///
3283 /// # Returns
3284 ///
3285 /// Indicates whether the operation succeeded.
3286 ///
3287 /// <div class="warning">
3288 ///
3289 /// **Experimental.** This API is part of an experimental wire-protocol surface
3290 /// and may change or be removed in future SDK or CLI releases. Pin both the
3291 /// SDK and CLI versions if your code depends on it.
3292 ///
3293 /// </div>
3294 pub async fn set_approve_all(
3295 &self,
3296 params: PermissionsSetApproveAllRequest,
3297 ) -> Result<PermissionsSetApproveAllResult, Error> {
3298 let mut wire_params = serde_json::to_value(params)?;
3299 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3300 let _value = self
3301 .session
3302 .client()
3303 .call(
3304 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
3305 Some(wire_params),
3306 )
3307 .await?;
3308 Ok(serde_json::from_value(_value)?)
3309 }
3310
3311 /// Adds or removes session-scoped or location-scoped permission rules.
3312 ///
3313 /// Wire method: `session.permissions.modifyRules`.
3314 ///
3315 /// # Parameters
3316 ///
3317 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
3318 ///
3319 /// # Returns
3320 ///
3321 /// Indicates whether the operation succeeded.
3322 ///
3323 /// <div class="warning">
3324 ///
3325 /// **Experimental.** This API is part of an experimental wire-protocol surface
3326 /// and may change or be removed in future SDK or CLI releases. Pin both the
3327 /// SDK and CLI versions if your code depends on it.
3328 ///
3329 /// </div>
3330 pub async fn modify_rules(
3331 &self,
3332 params: PermissionsModifyRulesParams,
3333 ) -> Result<PermissionsModifyRulesResult, Error> {
3334 let mut wire_params = serde_json::to_value(params)?;
3335 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3336 let _value = self
3337 .session
3338 .client()
3339 .call(
3340 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
3341 Some(wire_params),
3342 )
3343 .await?;
3344 Ok(serde_json::from_value(_value)?)
3345 }
3346
3347 /// Sets whether the client wants permission prompts bridged into session events.
3348 ///
3349 /// Wire method: `session.permissions.setRequired`.
3350 ///
3351 /// # Parameters
3352 ///
3353 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
3354 ///
3355 /// # Returns
3356 ///
3357 /// Indicates whether the operation succeeded.
3358 ///
3359 /// <div class="warning">
3360 ///
3361 /// **Experimental.** This API is part of an experimental wire-protocol surface
3362 /// and may change or be removed in future SDK or CLI releases. Pin both the
3363 /// SDK and CLI versions if your code depends on it.
3364 ///
3365 /// </div>
3366 pub async fn set_required(
3367 &self,
3368 params: PermissionsSetRequiredRequest,
3369 ) -> Result<PermissionsSetRequiredResult, Error> {
3370 let mut wire_params = serde_json::to_value(params)?;
3371 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3372 let _value = self
3373 .session
3374 .client()
3375 .call(
3376 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
3377 Some(wire_params),
3378 )
3379 .await?;
3380 Ok(serde_json::from_value(_value)?)
3381 }
3382
3383 /// Clears session-scoped tool permission approvals.
3384 ///
3385 /// Wire method: `session.permissions.resetSessionApprovals`.
3386 ///
3387 /// # Returns
3388 ///
3389 /// Indicates whether the operation succeeded.
3390 ///
3391 /// <div class="warning">
3392 ///
3393 /// **Experimental.** This API is part of an experimental wire-protocol surface
3394 /// and may change or be removed in future SDK or CLI releases. Pin both the
3395 /// SDK and CLI versions if your code depends on it.
3396 ///
3397 /// </div>
3398 pub async fn reset_session_approvals(
3399 &self,
3400 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
3401 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3402 let _value = self
3403 .session
3404 .client()
3405 .call(
3406 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
3407 Some(wire_params),
3408 )
3409 .await?;
3410 Ok(serde_json::from_value(_value)?)
3411 }
3412
3413 /// Notifies the runtime that a permission prompt UI has been shown to the user.
3414 ///
3415 /// Wire method: `session.permissions.notifyPromptShown`.
3416 ///
3417 /// # Parameters
3418 ///
3419 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
3420 ///
3421 /// # Returns
3422 ///
3423 /// Indicates whether the operation succeeded.
3424 ///
3425 /// <div class="warning">
3426 ///
3427 /// **Experimental.** This API is part of an experimental wire-protocol surface
3428 /// and may change or be removed in future SDK or CLI releases. Pin both the
3429 /// SDK and CLI versions if your code depends on it.
3430 ///
3431 /// </div>
3432 pub async fn notify_prompt_shown(
3433 &self,
3434 params: PermissionPromptShownNotification,
3435 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
3436 let mut wire_params = serde_json::to_value(params)?;
3437 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3438 let _value = self
3439 .session
3440 .client()
3441 .call(
3442 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
3443 Some(wire_params),
3444 )
3445 .await?;
3446 Ok(serde_json::from_value(_value)?)
3447 }
3448}
3449
3450/// `session.permissions.folderTrust.*` RPCs.
3451#[derive(Clone, Copy)]
3452pub struct SessionRpcPermissionsFolderTrust<'a> {
3453 pub(crate) session: &'a Session,
3454}
3455
3456impl<'a> SessionRpcPermissionsFolderTrust<'a> {
3457 /// Reports whether a folder is trusted according to the user's folder trust state.
3458 ///
3459 /// Wire method: `session.permissions.folderTrust.isTrusted`.
3460 ///
3461 /// # Parameters
3462 ///
3463 /// * `params` - Folder path to check for trust.
3464 ///
3465 /// # Returns
3466 ///
3467 /// Folder trust check result.
3468 ///
3469 /// <div class="warning">
3470 ///
3471 /// **Experimental.** This API is part of an experimental wire-protocol surface
3472 /// and may change or be removed in future SDK or CLI releases. Pin both the
3473 /// SDK and CLI versions if your code depends on it.
3474 ///
3475 /// </div>
3476 pub async fn is_trusted(
3477 &self,
3478 params: FolderTrustCheckParams,
3479 ) -> Result<FolderTrustCheckResult, Error> {
3480 let mut wire_params = serde_json::to_value(params)?;
3481 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3482 let _value = self
3483 .session
3484 .client()
3485 .call(
3486 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
3487 Some(wire_params),
3488 )
3489 .await?;
3490 Ok(serde_json::from_value(_value)?)
3491 }
3492
3493 /// Adds a folder to the user's trusted folders list.
3494 ///
3495 /// Wire method: `session.permissions.folderTrust.addTrusted`.
3496 ///
3497 /// # Parameters
3498 ///
3499 /// * `params` - Folder path to add to trusted folders.
3500 ///
3501 /// # Returns
3502 ///
3503 /// Indicates whether the operation succeeded.
3504 ///
3505 /// <div class="warning">
3506 ///
3507 /// **Experimental.** This API is part of an experimental wire-protocol surface
3508 /// and may change or be removed in future SDK or CLI releases. Pin both the
3509 /// SDK and CLI versions if your code depends on it.
3510 ///
3511 /// </div>
3512 pub async fn add_trusted(
3513 &self,
3514 params: FolderTrustAddParams,
3515 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
3516 let mut wire_params = serde_json::to_value(params)?;
3517 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3518 let _value = self
3519 .session
3520 .client()
3521 .call(
3522 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
3523 Some(wire_params),
3524 )
3525 .await?;
3526 Ok(serde_json::from_value(_value)?)
3527 }
3528}
3529
3530/// `session.permissions.locations.*` RPCs.
3531#[derive(Clone, Copy)]
3532pub struct SessionRpcPermissionsLocations<'a> {
3533 pub(crate) session: &'a Session,
3534}
3535
3536impl<'a> SessionRpcPermissionsLocations<'a> {
3537 /// Resolves the permission location key and type for a working directory.
3538 ///
3539 /// Wire method: `session.permissions.locations.resolve`.
3540 ///
3541 /// # Parameters
3542 ///
3543 /// * `params` - Working directory to resolve into a location-permissions key.
3544 ///
3545 /// # Returns
3546 ///
3547 /// Resolved location-permissions key and type.
3548 ///
3549 /// <div class="warning">
3550 ///
3551 /// **Experimental.** This API is part of an experimental wire-protocol surface
3552 /// and may change or be removed in future SDK or CLI releases. Pin both the
3553 /// SDK and CLI versions if your code depends on it.
3554 ///
3555 /// </div>
3556 pub async fn resolve(
3557 &self,
3558 params: PermissionLocationResolveParams,
3559 ) -> Result<PermissionLocationResolveResult, Error> {
3560 let mut wire_params = serde_json::to_value(params)?;
3561 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3562 let _value = self
3563 .session
3564 .client()
3565 .call(
3566 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
3567 Some(wire_params),
3568 )
3569 .await?;
3570 Ok(serde_json::from_value(_value)?)
3571 }
3572
3573 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
3574 ///
3575 /// Wire method: `session.permissions.locations.apply`.
3576 ///
3577 /// # Parameters
3578 ///
3579 /// * `params` - Working directory to load persisted location permissions for.
3580 ///
3581 /// # Returns
3582 ///
3583 /// Summary of persisted location permissions applied to the session.
3584 ///
3585 /// <div class="warning">
3586 ///
3587 /// **Experimental.** This API is part of an experimental wire-protocol surface
3588 /// and may change or be removed in future SDK or CLI releases. Pin both the
3589 /// SDK and CLI versions if your code depends on it.
3590 ///
3591 /// </div>
3592 pub async fn apply(
3593 &self,
3594 params: PermissionLocationApplyParams,
3595 ) -> Result<PermissionLocationApplyResult, Error> {
3596 let mut wire_params = serde_json::to_value(params)?;
3597 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3598 let _value = self
3599 .session
3600 .client()
3601 .call(
3602 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
3603 Some(wire_params),
3604 )
3605 .await?;
3606 Ok(serde_json::from_value(_value)?)
3607 }
3608
3609 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
3610 ///
3611 /// Wire method: `session.permissions.locations.addToolApproval`.
3612 ///
3613 /// # Parameters
3614 ///
3615 /// * `params` - Location-scoped tool approval to persist.
3616 ///
3617 /// # Returns
3618 ///
3619 /// Indicates whether the operation succeeded.
3620 ///
3621 /// <div class="warning">
3622 ///
3623 /// **Experimental.** This API is part of an experimental wire-protocol surface
3624 /// and may change or be removed in future SDK or CLI releases. Pin both the
3625 /// SDK and CLI versions if your code depends on it.
3626 ///
3627 /// </div>
3628 pub async fn add_tool_approval(
3629 &self,
3630 params: PermissionLocationAddToolApprovalParams,
3631 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
3632 let mut wire_params = serde_json::to_value(params)?;
3633 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3634 let _value = self
3635 .session
3636 .client()
3637 .call(
3638 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
3639 Some(wire_params),
3640 )
3641 .await?;
3642 Ok(serde_json::from_value(_value)?)
3643 }
3644}
3645
3646/// `session.permissions.paths.*` RPCs.
3647#[derive(Clone, Copy)]
3648pub struct SessionRpcPermissionsPaths<'a> {
3649 pub(crate) session: &'a Session,
3650}
3651
3652impl<'a> SessionRpcPermissionsPaths<'a> {
3653 /// Returns the session's allowed directories and primary working directory.
3654 ///
3655 /// Wire method: `session.permissions.paths.list`.
3656 ///
3657 /// # Returns
3658 ///
3659 /// Snapshot of the session's allow-listed directories and primary working directory.
3660 ///
3661 /// <div class="warning">
3662 ///
3663 /// **Experimental.** This API is part of an experimental wire-protocol surface
3664 /// and may change or be removed in future SDK or CLI releases. Pin both the
3665 /// SDK and CLI versions if your code depends on it.
3666 ///
3667 /// </div>
3668 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
3669 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3670 let _value = self
3671 .session
3672 .client()
3673 .call(
3674 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
3675 Some(wire_params),
3676 )
3677 .await?;
3678 Ok(serde_json::from_value(_value)?)
3679 }
3680
3681 /// Adds a directory to the session's allow-list.
3682 ///
3683 /// Wire method: `session.permissions.paths.add`.
3684 ///
3685 /// # Parameters
3686 ///
3687 /// * `params` - Directory path to add to the session's allowed directories.
3688 ///
3689 /// # Returns
3690 ///
3691 /// Indicates whether the operation succeeded.
3692 ///
3693 /// <div class="warning">
3694 ///
3695 /// **Experimental.** This API is part of an experimental wire-protocol surface
3696 /// and may change or be removed in future SDK or CLI releases. Pin both the
3697 /// SDK and CLI versions if your code depends on it.
3698 ///
3699 /// </div>
3700 pub async fn add(
3701 &self,
3702 params: PermissionPathsAddParams,
3703 ) -> Result<PermissionsPathsAddResult, Error> {
3704 let mut wire_params = serde_json::to_value(params)?;
3705 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3706 let _value = self
3707 .session
3708 .client()
3709 .call(
3710 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
3711 Some(wire_params),
3712 )
3713 .await?;
3714 Ok(serde_json::from_value(_value)?)
3715 }
3716
3717 /// Updates the session's primary working directory used by the permission policy.
3718 ///
3719 /// Wire method: `session.permissions.paths.updatePrimary`.
3720 ///
3721 /// # Parameters
3722 ///
3723 /// * `params` - Directory path to set as the session's new primary working directory.
3724 ///
3725 /// # Returns
3726 ///
3727 /// Indicates whether the operation succeeded.
3728 ///
3729 /// <div class="warning">
3730 ///
3731 /// **Experimental.** This API is part of an experimental wire-protocol surface
3732 /// and may change or be removed in future SDK or CLI releases. Pin both the
3733 /// SDK and CLI versions if your code depends on it.
3734 ///
3735 /// </div>
3736 pub async fn update_primary(
3737 &self,
3738 params: PermissionPathsUpdatePrimaryParams,
3739 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
3740 let mut wire_params = serde_json::to_value(params)?;
3741 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3742 let _value = self
3743 .session
3744 .client()
3745 .call(
3746 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
3747 Some(wire_params),
3748 )
3749 .await?;
3750 Ok(serde_json::from_value(_value)?)
3751 }
3752
3753 /// Reports whether a path falls within any of the session's allowed directories.
3754 ///
3755 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
3756 ///
3757 /// # Parameters
3758 ///
3759 /// * `params` - Path to evaluate against the session's allowed directories.
3760 ///
3761 /// # Returns
3762 ///
3763 /// Indicates whether the supplied path is within the session's allowed directories.
3764 ///
3765 /// <div class="warning">
3766 ///
3767 /// **Experimental.** This API is part of an experimental wire-protocol surface
3768 /// and may change or be removed in future SDK or CLI releases. Pin both the
3769 /// SDK and CLI versions if your code depends on it.
3770 ///
3771 /// </div>
3772 pub async fn is_path_within_allowed_directories(
3773 &self,
3774 params: PermissionPathsAllowedCheckParams,
3775 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
3776 let mut wire_params = serde_json::to_value(params)?;
3777 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3778 let _value = self
3779 .session
3780 .client()
3781 .call(
3782 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
3783 Some(wire_params),
3784 )
3785 .await?;
3786 Ok(serde_json::from_value(_value)?)
3787 }
3788
3789 /// Reports whether a path falls within the session's workspace (primary) directory.
3790 ///
3791 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
3792 ///
3793 /// # Parameters
3794 ///
3795 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
3796 ///
3797 /// # Returns
3798 ///
3799 /// Indicates whether the supplied path is within the session's workspace directory.
3800 ///
3801 /// <div class="warning">
3802 ///
3803 /// **Experimental.** This API is part of an experimental wire-protocol surface
3804 /// and may change or be removed in future SDK or CLI releases. Pin both the
3805 /// SDK and CLI versions if your code depends on it.
3806 ///
3807 /// </div>
3808 pub async fn is_path_within_workspace(
3809 &self,
3810 params: PermissionPathsWorkspaceCheckParams,
3811 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
3812 let mut wire_params = serde_json::to_value(params)?;
3813 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3814 let _value = self
3815 .session
3816 .client()
3817 .call(
3818 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
3819 Some(wire_params),
3820 )
3821 .await?;
3822 Ok(serde_json::from_value(_value)?)
3823 }
3824}
3825
3826/// `session.permissions.urls.*` RPCs.
3827#[derive(Clone, Copy)]
3828pub struct SessionRpcPermissionsUrls<'a> {
3829 pub(crate) session: &'a Session,
3830}
3831
3832impl<'a> SessionRpcPermissionsUrls<'a> {
3833 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
3834 ///
3835 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
3836 ///
3837 /// # Parameters
3838 ///
3839 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
3840 ///
3841 /// # Returns
3842 ///
3843 /// Indicates whether the operation succeeded.
3844 ///
3845 /// <div class="warning">
3846 ///
3847 /// **Experimental.** This API is part of an experimental wire-protocol surface
3848 /// and may change or be removed in future SDK or CLI releases. Pin both the
3849 /// SDK and CLI versions if your code depends on it.
3850 ///
3851 /// </div>
3852 pub async fn set_unrestricted_mode(
3853 &self,
3854 params: PermissionUrlsSetUnrestrictedModeParams,
3855 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
3856 let mut wire_params = serde_json::to_value(params)?;
3857 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3858 let _value = self
3859 .session
3860 .client()
3861 .call(
3862 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
3863 Some(wire_params),
3864 )
3865 .await?;
3866 Ok(serde_json::from_value(_value)?)
3867 }
3868}
3869
3870/// `session.plan.*` RPCs.
3871#[derive(Clone, Copy)]
3872pub struct SessionRpcPlan<'a> {
3873 pub(crate) session: &'a Session,
3874}
3875
3876impl<'a> SessionRpcPlan<'a> {
3877 /// Reads the session plan file from the workspace.
3878 ///
3879 /// Wire method: `session.plan.read`.
3880 ///
3881 /// # Returns
3882 ///
3883 /// Existence, contents, and resolved path of the session plan file.
3884 ///
3885 /// <div class="warning">
3886 ///
3887 /// **Experimental.** This API is part of an experimental wire-protocol surface
3888 /// and may change or be removed in future SDK or CLI releases. Pin both the
3889 /// SDK and CLI versions if your code depends on it.
3890 ///
3891 /// </div>
3892 pub async fn read(&self) -> Result<PlanReadResult, Error> {
3893 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3894 let _value = self
3895 .session
3896 .client()
3897 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
3898 .await?;
3899 Ok(serde_json::from_value(_value)?)
3900 }
3901
3902 /// Writes new content to the session plan file.
3903 ///
3904 /// Wire method: `session.plan.update`.
3905 ///
3906 /// # Parameters
3907 ///
3908 /// * `params` - Replacement contents to write to the session plan file.
3909 ///
3910 /// <div class="warning">
3911 ///
3912 /// **Experimental.** This API is part of an experimental wire-protocol surface
3913 /// and may change or be removed in future SDK or CLI releases. Pin both the
3914 /// SDK and CLI versions if your code depends on it.
3915 ///
3916 /// </div>
3917 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
3918 let mut wire_params = serde_json::to_value(params)?;
3919 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3920 let _value = self
3921 .session
3922 .client()
3923 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
3924 .await?;
3925 Ok(())
3926 }
3927
3928 /// Deletes the session plan file from the workspace.
3929 ///
3930 /// Wire method: `session.plan.delete`.
3931 ///
3932 /// <div class="warning">
3933 ///
3934 /// **Experimental.** This API is part of an experimental wire-protocol surface
3935 /// and may change or be removed in future SDK or CLI releases. Pin both the
3936 /// SDK and CLI versions if your code depends on it.
3937 ///
3938 /// </div>
3939 pub async fn delete(&self) -> Result<(), Error> {
3940 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3941 let _value = self
3942 .session
3943 .client()
3944 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
3945 .await?;
3946 Ok(())
3947 }
3948}
3949
3950/// `session.plugins.*` RPCs.
3951#[derive(Clone, Copy)]
3952pub struct SessionRpcPlugins<'a> {
3953 pub(crate) session: &'a Session,
3954}
3955
3956impl<'a> SessionRpcPlugins<'a> {
3957 /// Lists plugins installed for the session.
3958 ///
3959 /// Wire method: `session.plugins.list`.
3960 ///
3961 /// # Returns
3962 ///
3963 /// Plugins installed for the session, with their enabled state and version metadata.
3964 ///
3965 /// <div class="warning">
3966 ///
3967 /// **Experimental.** This API is part of an experimental wire-protocol surface
3968 /// and may change or be removed in future SDK or CLI releases. Pin both the
3969 /// SDK and CLI versions if your code depends on it.
3970 ///
3971 /// </div>
3972 pub async fn list(&self) -> Result<PluginList, Error> {
3973 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3974 let _value = self
3975 .session
3976 .client()
3977 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
3978 .await?;
3979 Ok(serde_json::from_value(_value)?)
3980 }
3981}
3982
3983/// `session.queue.*` RPCs.
3984#[derive(Clone, Copy)]
3985pub struct SessionRpcQueue<'a> {
3986 pub(crate) session: &'a Session,
3987}
3988
3989impl<'a> SessionRpcQueue<'a> {
3990 /// Returns the local session's pending user-facing queued items and steering messages.
3991 ///
3992 /// Wire method: `session.queue.pendingItems`.
3993 ///
3994 /// # Returns
3995 ///
3996 /// Snapshot of the session's pending queued items and immediate-steering messages.
3997 ///
3998 /// <div class="warning">
3999 ///
4000 /// **Experimental.** This API is part of an experimental wire-protocol surface
4001 /// and may change or be removed in future SDK or CLI releases. Pin both the
4002 /// SDK and CLI versions if your code depends on it.
4003 ///
4004 /// </div>
4005 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
4006 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4007 let _value = self
4008 .session
4009 .client()
4010 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
4011 .await?;
4012 Ok(serde_json::from_value(_value)?)
4013 }
4014
4015 /// Removes the most recently queued user-facing item (LIFO).
4016 ///
4017 /// Wire method: `session.queue.removeMostRecent`.
4018 ///
4019 /// # Returns
4020 ///
4021 /// Indicates whether a user-facing pending item was removed.
4022 ///
4023 /// <div class="warning">
4024 ///
4025 /// **Experimental.** This API is part of an experimental wire-protocol surface
4026 /// and may change or be removed in future SDK or CLI releases. Pin both the
4027 /// SDK and CLI versions if your code depends on it.
4028 ///
4029 /// </div>
4030 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
4031 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4032 let _value = self
4033 .session
4034 .client()
4035 .call(
4036 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
4037 Some(wire_params),
4038 )
4039 .await?;
4040 Ok(serde_json::from_value(_value)?)
4041 }
4042
4043 /// Clears all pending queued items on the local session.
4044 ///
4045 /// Wire method: `session.queue.clear`.
4046 ///
4047 /// <div class="warning">
4048 ///
4049 /// **Experimental.** This API is part of an experimental wire-protocol surface
4050 /// and may change or be removed in future SDK or CLI releases. Pin both the
4051 /// SDK and CLI versions if your code depends on it.
4052 ///
4053 /// </div>
4054 pub async fn clear(&self) -> Result<(), Error> {
4055 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4056 let _value = self
4057 .session
4058 .client()
4059 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
4060 .await?;
4061 Ok(())
4062 }
4063}
4064
4065/// `session.remote.*` RPCs.
4066#[derive(Clone, Copy)]
4067pub struct SessionRpcRemote<'a> {
4068 pub(crate) session: &'a Session,
4069}
4070
4071impl<'a> SessionRpcRemote<'a> {
4072 /// Enables remote session export or steering.
4073 ///
4074 /// Wire method: `session.remote.enable`.
4075 ///
4076 /// # Parameters
4077 ///
4078 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
4079 ///
4080 /// # Returns
4081 ///
4082 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
4083 ///
4084 /// <div class="warning">
4085 ///
4086 /// **Experimental.** This API is part of an experimental wire-protocol surface
4087 /// and may change or be removed in future SDK or CLI releases. Pin both the
4088 /// SDK and CLI versions if your code depends on it.
4089 ///
4090 /// </div>
4091 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
4092 let mut wire_params = serde_json::to_value(params)?;
4093 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4094 let _value = self
4095 .session
4096 .client()
4097 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
4098 .await?;
4099 Ok(serde_json::from_value(_value)?)
4100 }
4101
4102 /// Disables remote session export and steering.
4103 ///
4104 /// Wire method: `session.remote.disable`.
4105 ///
4106 /// <div class="warning">
4107 ///
4108 /// **Experimental.** This API is part of an experimental wire-protocol surface
4109 /// and may change or be removed in future SDK or CLI releases. Pin both the
4110 /// SDK and CLI versions if your code depends on it.
4111 ///
4112 /// </div>
4113 pub async fn disable(&self) -> Result<(), Error> {
4114 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4115 let _value = self
4116 .session
4117 .client()
4118 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
4119 .await?;
4120 Ok(())
4121 }
4122
4123 /// Persists a remote-steerability change emitted by the host as a session event.
4124 ///
4125 /// Wire method: `session.remote.notifySteerableChanged`.
4126 ///
4127 /// # Parameters
4128 ///
4129 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
4130 ///
4131 /// # Returns
4132 ///
4133 /// 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.
4134 ///
4135 /// <div class="warning">
4136 ///
4137 /// **Experimental.** This API is part of an experimental wire-protocol surface
4138 /// and may change or be removed in future SDK or CLI releases. Pin both the
4139 /// SDK and CLI versions if your code depends on it.
4140 ///
4141 /// </div>
4142 pub async fn notify_steerable_changed(
4143 &self,
4144 params: RemoteNotifySteerableChangedRequest,
4145 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
4146 let mut wire_params = serde_json::to_value(params)?;
4147 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4148 let _value = self
4149 .session
4150 .client()
4151 .call(
4152 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
4153 Some(wire_params),
4154 )
4155 .await?;
4156 Ok(serde_json::from_value(_value)?)
4157 }
4158}
4159
4160/// `session.schedule.*` RPCs.
4161#[derive(Clone, Copy)]
4162pub struct SessionRpcSchedule<'a> {
4163 pub(crate) session: &'a Session,
4164}
4165
4166impl<'a> SessionRpcSchedule<'a> {
4167 /// Lists the session's currently active scheduled prompts.
4168 ///
4169 /// Wire method: `session.schedule.list`.
4170 ///
4171 /// # Returns
4172 ///
4173 /// Snapshot of the currently active recurring prompts for this session.
4174 ///
4175 /// <div class="warning">
4176 ///
4177 /// **Experimental.** This API is part of an experimental wire-protocol surface
4178 /// and may change or be removed in future SDK or CLI releases. Pin both the
4179 /// SDK and CLI versions if your code depends on it.
4180 ///
4181 /// </div>
4182 pub async fn list(&self) -> Result<ScheduleList, Error> {
4183 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4184 let _value = self
4185 .session
4186 .client()
4187 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
4188 .await?;
4189 Ok(serde_json::from_value(_value)?)
4190 }
4191
4192 /// Removes a scheduled prompt by id.
4193 ///
4194 /// Wire method: `session.schedule.stop`.
4195 ///
4196 /// # Parameters
4197 ///
4198 /// * `params` - Identifier of the scheduled prompt to remove.
4199 ///
4200 /// # Returns
4201 ///
4202 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
4203 ///
4204 /// <div class="warning">
4205 ///
4206 /// **Experimental.** This API is part of an experimental wire-protocol surface
4207 /// and may change or be removed in future SDK or CLI releases. Pin both the
4208 /// SDK and CLI versions if your code depends on it.
4209 ///
4210 /// </div>
4211 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
4212 let mut wire_params = serde_json::to_value(params)?;
4213 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4214 let _value = self
4215 .session
4216 .client()
4217 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
4218 .await?;
4219 Ok(serde_json::from_value(_value)?)
4220 }
4221}
4222
4223/// `session.shell.*` RPCs.
4224#[derive(Clone, Copy)]
4225pub struct SessionRpcShell<'a> {
4226 pub(crate) session: &'a Session,
4227}
4228
4229impl<'a> SessionRpcShell<'a> {
4230 /// Starts a shell command and streams output through session notifications.
4231 ///
4232 /// Wire method: `session.shell.exec`.
4233 ///
4234 /// # Parameters
4235 ///
4236 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
4237 ///
4238 /// # Returns
4239 ///
4240 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
4241 ///
4242 /// <div class="warning">
4243 ///
4244 /// **Experimental.** This API is part of an experimental wire-protocol surface
4245 /// and may change or be removed in future SDK or CLI releases. Pin both the
4246 /// SDK and CLI versions if your code depends on it.
4247 ///
4248 /// </div>
4249 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
4250 let mut wire_params = serde_json::to_value(params)?;
4251 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4252 let _value = self
4253 .session
4254 .client()
4255 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
4256 .await?;
4257 Ok(serde_json::from_value(_value)?)
4258 }
4259
4260 /// Sends a signal to a shell process previously started via "shell.exec".
4261 ///
4262 /// Wire method: `session.shell.kill`.
4263 ///
4264 /// # Parameters
4265 ///
4266 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
4267 ///
4268 /// # Returns
4269 ///
4270 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
4271 ///
4272 /// <div class="warning">
4273 ///
4274 /// **Experimental.** This API is part of an experimental wire-protocol surface
4275 /// and may change or be removed in future SDK or CLI releases. Pin both the
4276 /// SDK and CLI versions if your code depends on it.
4277 ///
4278 /// </div>
4279 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
4280 let mut wire_params = serde_json::to_value(params)?;
4281 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4282 let _value = self
4283 .session
4284 .client()
4285 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
4286 .await?;
4287 Ok(serde_json::from_value(_value)?)
4288 }
4289}
4290
4291/// `session.skills.*` RPCs.
4292#[derive(Clone, Copy)]
4293pub struct SessionRpcSkills<'a> {
4294 pub(crate) session: &'a Session,
4295}
4296
4297impl<'a> SessionRpcSkills<'a> {
4298 /// Lists skills available to the session.
4299 ///
4300 /// Wire method: `session.skills.list`.
4301 ///
4302 /// # Returns
4303 ///
4304 /// Skills available to the session, with their enabled state.
4305 ///
4306 /// <div class="warning">
4307 ///
4308 /// **Experimental.** This API is part of an experimental wire-protocol surface
4309 /// and may change or be removed in future SDK or CLI releases. Pin both the
4310 /// SDK and CLI versions if your code depends on it.
4311 ///
4312 /// </div>
4313 pub async fn list(&self) -> Result<SkillList, Error> {
4314 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4315 let _value = self
4316 .session
4317 .client()
4318 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
4319 .await?;
4320 Ok(serde_json::from_value(_value)?)
4321 }
4322
4323 /// Returns the skills that have been invoked during this session.
4324 ///
4325 /// Wire method: `session.skills.getInvoked`.
4326 ///
4327 /// # Returns
4328 ///
4329 /// Skills invoked during this session, ordered by invocation time (most recent last).
4330 ///
4331 /// <div class="warning">
4332 ///
4333 /// **Experimental.** This API is part of an experimental wire-protocol surface
4334 /// and may change or be removed in future SDK or CLI releases. Pin both the
4335 /// SDK and CLI versions if your code depends on it.
4336 ///
4337 /// </div>
4338 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
4339 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4340 let _value = self
4341 .session
4342 .client()
4343 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
4344 .await?;
4345 Ok(serde_json::from_value(_value)?)
4346 }
4347
4348 /// Enables a skill for the session.
4349 ///
4350 /// Wire method: `session.skills.enable`.
4351 ///
4352 /// # Parameters
4353 ///
4354 /// * `params` - Name of the skill to enable for the session.
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 enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
4364 let mut wire_params = serde_json::to_value(params)?;
4365 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4366 let _value = self
4367 .session
4368 .client()
4369 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
4370 .await?;
4371 Ok(())
4372 }
4373
4374 /// Disables a skill for the session.
4375 ///
4376 /// Wire method: `session.skills.disable`.
4377 ///
4378 /// # Parameters
4379 ///
4380 /// * `params` - Name of the skill to disable for the session.
4381 ///
4382 /// <div class="warning">
4383 ///
4384 /// **Experimental.** This API is part of an experimental wire-protocol surface
4385 /// and may change or be removed in future SDK or CLI releases. Pin both the
4386 /// SDK and CLI versions if your code depends on it.
4387 ///
4388 /// </div>
4389 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
4390 let mut wire_params = serde_json::to_value(params)?;
4391 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4392 let _value = self
4393 .session
4394 .client()
4395 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
4396 .await?;
4397 Ok(())
4398 }
4399
4400 /// Reloads skill definitions for the session.
4401 ///
4402 /// Wire method: `session.skills.reload`.
4403 ///
4404 /// # Returns
4405 ///
4406 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
4407 ///
4408 /// <div class="warning">
4409 ///
4410 /// **Experimental.** This API is part of an experimental wire-protocol surface
4411 /// and may change or be removed in future SDK or CLI releases. Pin both the
4412 /// SDK and CLI versions if your code depends on it.
4413 ///
4414 /// </div>
4415 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
4416 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4417 let _value = self
4418 .session
4419 .client()
4420 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
4421 .await?;
4422 Ok(serde_json::from_value(_value)?)
4423 }
4424
4425 /// Ensures the session's skill definitions have been loaded from disk.
4426 ///
4427 /// Wire method: `session.skills.ensureLoaded`.
4428 ///
4429 /// <div class="warning">
4430 ///
4431 /// **Experimental.** This API is part of an experimental wire-protocol surface
4432 /// and may change or be removed in future SDK or CLI releases. Pin both the
4433 /// SDK and CLI versions if your code depends on it.
4434 ///
4435 /// </div>
4436 pub async fn ensure_loaded(&self) -> Result<(), Error> {
4437 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4438 let _value = self
4439 .session
4440 .client()
4441 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
4442 .await?;
4443 Ok(())
4444 }
4445}
4446
4447/// `session.tasks.*` RPCs.
4448#[derive(Clone, Copy)]
4449pub struct SessionRpcTasks<'a> {
4450 pub(crate) session: &'a Session,
4451}
4452
4453impl<'a> SessionRpcTasks<'a> {
4454 /// Starts a background agent task in the session.
4455 ///
4456 /// Wire method: `session.tasks.startAgent`.
4457 ///
4458 /// # Parameters
4459 ///
4460 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
4461 ///
4462 /// # Returns
4463 ///
4464 /// Identifier assigned to the newly started background agent task.
4465 ///
4466 /// <div class="warning">
4467 ///
4468 /// **Experimental.** This API is part of an experimental wire-protocol surface
4469 /// and may change or be removed in future SDK or CLI releases. Pin both the
4470 /// SDK and CLI versions if your code depends on it.
4471 ///
4472 /// </div>
4473 pub async fn start_agent(
4474 &self,
4475 params: TasksStartAgentRequest,
4476 ) -> Result<TasksStartAgentResult, Error> {
4477 let mut wire_params = serde_json::to_value(params)?;
4478 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4479 let _value = self
4480 .session
4481 .client()
4482 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
4483 .await?;
4484 Ok(serde_json::from_value(_value)?)
4485 }
4486
4487 /// Lists background tasks tracked by the session.
4488 ///
4489 /// Wire method: `session.tasks.list`.
4490 ///
4491 /// # Returns
4492 ///
4493 /// Background tasks currently tracked by the session.
4494 ///
4495 /// <div class="warning">
4496 ///
4497 /// **Experimental.** This API is part of an experimental wire-protocol surface
4498 /// and may change or be removed in future SDK or CLI releases. Pin both the
4499 /// SDK and CLI versions if your code depends on it.
4500 ///
4501 /// </div>
4502 pub async fn list(&self) -> Result<TaskList, Error> {
4503 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4504 let _value = self
4505 .session
4506 .client()
4507 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
4508 .await?;
4509 Ok(serde_json::from_value(_value)?)
4510 }
4511
4512 /// Refreshes metadata for any detached background shells the runtime knows about.
4513 ///
4514 /// Wire method: `session.tasks.refresh`.
4515 ///
4516 /// # Returns
4517 ///
4518 /// 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.
4519 ///
4520 /// <div class="warning">
4521 ///
4522 /// **Experimental.** This API is part of an experimental wire-protocol surface
4523 /// and may change or be removed in future SDK or CLI releases. Pin both the
4524 /// SDK and CLI versions if your code depends on it.
4525 ///
4526 /// </div>
4527 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
4528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4529 let _value = self
4530 .session
4531 .client()
4532 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
4533 .await?;
4534 Ok(serde_json::from_value(_value)?)
4535 }
4536
4537 /// Waits for all in-flight background tasks and any follow-up turns to settle.
4538 ///
4539 /// Wire method: `session.tasks.waitForPending`.
4540 ///
4541 /// # Returns
4542 ///
4543 /// 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).
4544 ///
4545 /// <div class="warning">
4546 ///
4547 /// **Experimental.** This API is part of an experimental wire-protocol surface
4548 /// and may change or be removed in future SDK or CLI releases. Pin both the
4549 /// SDK and CLI versions if your code depends on it.
4550 ///
4551 /// </div>
4552 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
4553 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4554 let _value = self
4555 .session
4556 .client()
4557 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
4558 .await?;
4559 Ok(serde_json::from_value(_value)?)
4560 }
4561
4562 /// Returns progress information for a background task by ID.
4563 ///
4564 /// Wire method: `session.tasks.getProgress`.
4565 ///
4566 /// # Parameters
4567 ///
4568 /// * `params` - Identifier of the background task to fetch progress for.
4569 ///
4570 /// # Returns
4571 ///
4572 /// Progress information for the task, or null when no task with that ID is tracked.
4573 ///
4574 /// <div class="warning">
4575 ///
4576 /// **Experimental.** This API is part of an experimental wire-protocol surface
4577 /// and may change or be removed in future SDK or CLI releases. Pin both the
4578 /// SDK and CLI versions if your code depends on it.
4579 ///
4580 /// </div>
4581 pub async fn get_progress(
4582 &self,
4583 params: TasksGetProgressRequest,
4584 ) -> Result<TasksGetProgressResult, Error> {
4585 let mut wire_params = serde_json::to_value(params)?;
4586 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4587 let _value = self
4588 .session
4589 .client()
4590 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
4591 .await?;
4592 Ok(serde_json::from_value(_value)?)
4593 }
4594
4595 /// Returns the first sync-waiting task that can currently be promoted to background mode.
4596 ///
4597 /// Wire method: `session.tasks.getCurrentPromotable`.
4598 ///
4599 /// # Returns
4600 ///
4601 /// The first sync-waiting task that can currently be promoted to background mode.
4602 ///
4603 /// <div class="warning">
4604 ///
4605 /// **Experimental.** This API is part of an experimental wire-protocol surface
4606 /// and may change or be removed in future SDK or CLI releases. Pin both the
4607 /// SDK and CLI versions if your code depends on it.
4608 ///
4609 /// </div>
4610 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
4611 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4612 let _value = self
4613 .session
4614 .client()
4615 .call(
4616 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
4617 Some(wire_params),
4618 )
4619 .await?;
4620 Ok(serde_json::from_value(_value)?)
4621 }
4622
4623 /// Promotes an eligible synchronously-waited task so it continues running in the background.
4624 ///
4625 /// Wire method: `session.tasks.promoteToBackground`.
4626 ///
4627 /// # Parameters
4628 ///
4629 /// * `params` - Identifier of the task to promote to background mode.
4630 ///
4631 /// # Returns
4632 ///
4633 /// Indicates whether the task was successfully promoted to background mode.
4634 ///
4635 /// <div class="warning">
4636 ///
4637 /// **Experimental.** This API is part of an experimental wire-protocol surface
4638 /// and may change or be removed in future SDK or CLI releases. Pin both the
4639 /// SDK and CLI versions if your code depends on it.
4640 ///
4641 /// </div>
4642 pub async fn promote_to_background(
4643 &self,
4644 params: TasksPromoteToBackgroundRequest,
4645 ) -> Result<TasksPromoteToBackgroundResult, Error> {
4646 let mut wire_params = serde_json::to_value(params)?;
4647 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4648 let _value = self
4649 .session
4650 .client()
4651 .call(
4652 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
4653 Some(wire_params),
4654 )
4655 .await?;
4656 Ok(serde_json::from_value(_value)?)
4657 }
4658
4659 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
4660 ///
4661 /// Wire method: `session.tasks.promoteCurrentToBackground`.
4662 ///
4663 /// # Returns
4664 ///
4665 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
4666 ///
4667 /// <div class="warning">
4668 ///
4669 /// **Experimental.** This API is part of an experimental wire-protocol surface
4670 /// and may change or be removed in future SDK or CLI releases. Pin both the
4671 /// SDK and CLI versions if your code depends on it.
4672 ///
4673 /// </div>
4674 pub async fn promote_current_to_background(
4675 &self,
4676 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
4677 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4678 let _value = self
4679 .session
4680 .client()
4681 .call(
4682 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
4683 Some(wire_params),
4684 )
4685 .await?;
4686 Ok(serde_json::from_value(_value)?)
4687 }
4688
4689 /// Cancels a background task.
4690 ///
4691 /// Wire method: `session.tasks.cancel`.
4692 ///
4693 /// # Parameters
4694 ///
4695 /// * `params` - Identifier of the background task to cancel.
4696 ///
4697 /// # Returns
4698 ///
4699 /// Indicates whether the background task was successfully cancelled.
4700 ///
4701 /// <div class="warning">
4702 ///
4703 /// **Experimental.** This API is part of an experimental wire-protocol surface
4704 /// and may change or be removed in future SDK or CLI releases. Pin both the
4705 /// SDK and CLI versions if your code depends on it.
4706 ///
4707 /// </div>
4708 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
4709 let mut wire_params = serde_json::to_value(params)?;
4710 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4711 let _value = self
4712 .session
4713 .client()
4714 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
4715 .await?;
4716 Ok(serde_json::from_value(_value)?)
4717 }
4718
4719 /// Removes a completed or cancelled background task from tracking.
4720 ///
4721 /// Wire method: `session.tasks.remove`.
4722 ///
4723 /// # Parameters
4724 ///
4725 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
4726 ///
4727 /// # Returns
4728 ///
4729 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
4730 ///
4731 /// <div class="warning">
4732 ///
4733 /// **Experimental.** This API is part of an experimental wire-protocol surface
4734 /// and may change or be removed in future SDK or CLI releases. Pin both the
4735 /// SDK and CLI versions if your code depends on it.
4736 ///
4737 /// </div>
4738 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
4739 let mut wire_params = serde_json::to_value(params)?;
4740 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4741 let _value = self
4742 .session
4743 .client()
4744 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
4745 .await?;
4746 Ok(serde_json::from_value(_value)?)
4747 }
4748
4749 /// Sends a message to a background agent task.
4750 ///
4751 /// Wire method: `session.tasks.sendMessage`.
4752 ///
4753 /// # Parameters
4754 ///
4755 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
4756 ///
4757 /// # Returns
4758 ///
4759 /// Indicates whether the message was delivered, with an error message when delivery failed.
4760 ///
4761 /// <div class="warning">
4762 ///
4763 /// **Experimental.** This API is part of an experimental wire-protocol surface
4764 /// and may change or be removed in future SDK or CLI releases. Pin both the
4765 /// SDK and CLI versions if your code depends on it.
4766 ///
4767 /// </div>
4768 pub async fn send_message(
4769 &self,
4770 params: TasksSendMessageRequest,
4771 ) -> Result<TasksSendMessageResult, Error> {
4772 let mut wire_params = serde_json::to_value(params)?;
4773 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4774 let _value = self
4775 .session
4776 .client()
4777 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
4778 .await?;
4779 Ok(serde_json::from_value(_value)?)
4780 }
4781}
4782
4783/// `session.telemetry.*` RPCs.
4784#[derive(Clone, Copy)]
4785pub struct SessionRpcTelemetry<'a> {
4786 pub(crate) session: &'a Session,
4787}
4788
4789impl<'a> SessionRpcTelemetry<'a> {
4790 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
4791 ///
4792 /// Wire method: `session.telemetry.setFeatureOverrides`.
4793 ///
4794 /// # Parameters
4795 ///
4796 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
4797 ///
4798 /// <div class="warning">
4799 ///
4800 /// **Experimental.** This API is part of an experimental wire-protocol surface
4801 /// and may change or be removed in future SDK or CLI releases. Pin both the
4802 /// SDK and CLI versions if your code depends on it.
4803 ///
4804 /// </div>
4805 pub async fn set_feature_overrides(
4806 &self,
4807 params: TelemetrySetFeatureOverridesRequest,
4808 ) -> Result<(), Error> {
4809 let mut wire_params = serde_json::to_value(params)?;
4810 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4811 let _value = self
4812 .session
4813 .client()
4814 .call(
4815 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
4816 Some(wire_params),
4817 )
4818 .await?;
4819 Ok(())
4820 }
4821}
4822
4823/// `session.tools.*` RPCs.
4824#[derive(Clone, Copy)]
4825pub struct SessionRpcTools<'a> {
4826 pub(crate) session: &'a Session,
4827}
4828
4829impl<'a> SessionRpcTools<'a> {
4830 /// Provides the result for a pending external tool call.
4831 ///
4832 /// Wire method: `session.tools.handlePendingToolCall`.
4833 ///
4834 /// # Parameters
4835 ///
4836 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
4837 ///
4838 /// # Returns
4839 ///
4840 /// Indicates whether the external tool call result was handled successfully.
4841 ///
4842 /// <div class="warning">
4843 ///
4844 /// **Experimental.** This API is part of an experimental wire-protocol surface
4845 /// and may change or be removed in future SDK or CLI releases. Pin both the
4846 /// SDK and CLI versions if your code depends on it.
4847 ///
4848 /// </div>
4849 pub async fn handle_pending_tool_call(
4850 &self,
4851 params: HandlePendingToolCallRequest,
4852 ) -> Result<HandlePendingToolCallResult, Error> {
4853 let mut wire_params = serde_json::to_value(params)?;
4854 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4855 let _value = self
4856 .session
4857 .client()
4858 .call(
4859 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
4860 Some(wire_params),
4861 )
4862 .await?;
4863 Ok(serde_json::from_value(_value)?)
4864 }
4865
4866 /// Resolves, builds, and validates the runtime tool list for the session.
4867 ///
4868 /// Wire method: `session.tools.initializeAndValidate`.
4869 ///
4870 /// # Returns
4871 ///
4872 /// 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.
4873 ///
4874 /// <div class="warning">
4875 ///
4876 /// **Experimental.** This API is part of an experimental wire-protocol surface
4877 /// and may change or be removed in future SDK or CLI releases. Pin both the
4878 /// SDK and CLI versions if your code depends on it.
4879 ///
4880 /// </div>
4881 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
4882 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4883 let _value = self
4884 .session
4885 .client()
4886 .call(
4887 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
4888 Some(wire_params),
4889 )
4890 .await?;
4891 Ok(serde_json::from_value(_value)?)
4892 }
4893}
4894
4895/// `session.ui.*` RPCs.
4896#[derive(Clone, Copy)]
4897pub struct SessionRpcUi<'a> {
4898 pub(crate) session: &'a Session,
4899}
4900
4901impl<'a> SessionRpcUi<'a> {
4902 /// Requests structured input from a UI-capable client.
4903 ///
4904 /// Wire method: `session.ui.elicitation`.
4905 ///
4906 /// # Parameters
4907 ///
4908 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
4909 ///
4910 /// # Returns
4911 ///
4912 /// The elicitation response (accept with form values, decline, or cancel)
4913 ///
4914 /// <div class="warning">
4915 ///
4916 /// **Experimental.** This API is part of an experimental wire-protocol surface
4917 /// and may change or be removed in future SDK or CLI releases. Pin both the
4918 /// SDK and CLI versions if your code depends on it.
4919 ///
4920 /// </div>
4921 pub async fn elicitation(
4922 &self,
4923 params: UIElicitationRequest,
4924 ) -> Result<UIElicitationResponse, Error> {
4925 let mut wire_params = serde_json::to_value(params)?;
4926 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4927 let _value = self
4928 .session
4929 .client()
4930 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
4931 .await?;
4932 Ok(serde_json::from_value(_value)?)
4933 }
4934
4935 /// Provides the user response for a pending elicitation request.
4936 ///
4937 /// Wire method: `session.ui.handlePendingElicitation`.
4938 ///
4939 /// # Parameters
4940 ///
4941 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
4942 ///
4943 /// # Returns
4944 ///
4945 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
4946 ///
4947 /// <div class="warning">
4948 ///
4949 /// **Experimental.** This API is part of an experimental wire-protocol surface
4950 /// and may change or be removed in future SDK or CLI releases. Pin both the
4951 /// SDK and CLI versions if your code depends on it.
4952 ///
4953 /// </div>
4954 pub async fn handle_pending_elicitation(
4955 &self,
4956 params: UIHandlePendingElicitationRequest,
4957 ) -> Result<UIElicitationResult, Error> {
4958 let mut wire_params = serde_json::to_value(params)?;
4959 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4960 let _value = self
4961 .session
4962 .client()
4963 .call(
4964 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
4965 Some(wire_params),
4966 )
4967 .await?;
4968 Ok(serde_json::from_value(_value)?)
4969 }
4970
4971 /// Resolves a pending `user_input.requested` event with the user's response.
4972 ///
4973 /// Wire method: `session.ui.handlePendingUserInput`.
4974 ///
4975 /// # Parameters
4976 ///
4977 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
4978 ///
4979 /// # Returns
4980 ///
4981 /// Indicates whether the pending UI request was resolved by this call.
4982 ///
4983 /// <div class="warning">
4984 ///
4985 /// **Experimental.** This API is part of an experimental wire-protocol surface
4986 /// and may change or be removed in future SDK or CLI releases. Pin both the
4987 /// SDK and CLI versions if your code depends on it.
4988 ///
4989 /// </div>
4990 pub async fn handle_pending_user_input(
4991 &self,
4992 params: UIHandlePendingUserInputRequest,
4993 ) -> Result<UIHandlePendingResult, Error> {
4994 let mut wire_params = serde_json::to_value(params)?;
4995 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4996 let _value = self
4997 .session
4998 .client()
4999 .call(
5000 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
5001 Some(wire_params),
5002 )
5003 .await?;
5004 Ok(serde_json::from_value(_value)?)
5005 }
5006
5007 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
5008 ///
5009 /// Wire method: `session.ui.handlePendingSampling`.
5010 ///
5011 /// # Parameters
5012 ///
5013 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
5014 ///
5015 /// # Returns
5016 ///
5017 /// Indicates whether the pending UI request was resolved by this call.
5018 ///
5019 /// <div class="warning">
5020 ///
5021 /// **Experimental.** This API is part of an experimental wire-protocol surface
5022 /// and may change or be removed in future SDK or CLI releases. Pin both the
5023 /// SDK and CLI versions if your code depends on it.
5024 ///
5025 /// </div>
5026 pub async fn handle_pending_sampling(
5027 &self,
5028 params: UIHandlePendingSamplingRequest,
5029 ) -> Result<UIHandlePendingResult, Error> {
5030 let mut wire_params = serde_json::to_value(params)?;
5031 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5032 let _value = self
5033 .session
5034 .client()
5035 .call(
5036 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
5037 Some(wire_params),
5038 )
5039 .await?;
5040 Ok(serde_json::from_value(_value)?)
5041 }
5042
5043 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
5044 ///
5045 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
5046 ///
5047 /// # Parameters
5048 ///
5049 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
5050 ///
5051 /// # Returns
5052 ///
5053 /// Indicates whether the pending UI request was resolved by this call.
5054 ///
5055 /// <div class="warning">
5056 ///
5057 /// **Experimental.** This API is part of an experimental wire-protocol surface
5058 /// and may change or be removed in future SDK or CLI releases. Pin both the
5059 /// SDK and CLI versions if your code depends on it.
5060 ///
5061 /// </div>
5062 pub async fn handle_pending_auto_mode_switch(
5063 &self,
5064 params: UIHandlePendingAutoModeSwitchRequest,
5065 ) -> Result<UIHandlePendingResult, Error> {
5066 let mut wire_params = serde_json::to_value(params)?;
5067 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5068 let _value = self
5069 .session
5070 .client()
5071 .call(
5072 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
5073 Some(wire_params),
5074 )
5075 .await?;
5076 Ok(serde_json::from_value(_value)?)
5077 }
5078
5079 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
5080 ///
5081 /// Wire method: `session.ui.handlePendingExitPlanMode`.
5082 ///
5083 /// # Parameters
5084 ///
5085 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
5086 ///
5087 /// # Returns
5088 ///
5089 /// Indicates whether the pending UI request was resolved by this call.
5090 ///
5091 /// <div class="warning">
5092 ///
5093 /// **Experimental.** This API is part of an experimental wire-protocol surface
5094 /// and may change or be removed in future SDK or CLI releases. Pin both the
5095 /// SDK and CLI versions if your code depends on it.
5096 ///
5097 /// </div>
5098 pub async fn handle_pending_exit_plan_mode(
5099 &self,
5100 params: UIHandlePendingExitPlanModeRequest,
5101 ) -> Result<UIHandlePendingResult, Error> {
5102 let mut wire_params = serde_json::to_value(params)?;
5103 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5104 let _value = self
5105 .session
5106 .client()
5107 .call(
5108 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
5109 Some(wire_params),
5110 )
5111 .await?;
5112 Ok(serde_json::from_value(_value)?)
5113 }
5114
5115 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
5116 ///
5117 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
5118 ///
5119 /// # Returns
5120 ///
5121 /// 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).
5122 ///
5123 /// <div class="warning">
5124 ///
5125 /// **Experimental.** This API is part of an experimental wire-protocol surface
5126 /// and may change or be removed in future SDK or CLI releases. Pin both the
5127 /// SDK and CLI versions if your code depends on it.
5128 ///
5129 /// </div>
5130 pub async fn register_direct_auto_mode_switch_handler(
5131 &self,
5132 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
5133 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5134 let _value = self
5135 .session
5136 .client()
5137 .call(
5138 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
5139 Some(wire_params),
5140 )
5141 .await?;
5142 Ok(serde_json::from_value(_value)?)
5143 }
5144
5145 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
5146 ///
5147 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
5148 ///
5149 /// # Parameters
5150 ///
5151 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
5152 ///
5153 /// # Returns
5154 ///
5155 /// Indicates whether the handle was active and the registration count was decremented.
5156 ///
5157 /// <div class="warning">
5158 ///
5159 /// **Experimental.** This API is part of an experimental wire-protocol surface
5160 /// and may change or be removed in future SDK or CLI releases. Pin both the
5161 /// SDK and CLI versions if your code depends on it.
5162 ///
5163 /// </div>
5164 pub async fn unregister_direct_auto_mode_switch_handler(
5165 &self,
5166 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
5167 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
5168 let mut wire_params = serde_json::to_value(params)?;
5169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5170 let _value = self
5171 .session
5172 .client()
5173 .call(
5174 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
5175 Some(wire_params),
5176 )
5177 .await?;
5178 Ok(serde_json::from_value(_value)?)
5179 }
5180}
5181
5182/// `session.usage.*` RPCs.
5183#[derive(Clone, Copy)]
5184pub struct SessionRpcUsage<'a> {
5185 pub(crate) session: &'a Session,
5186}
5187
5188impl<'a> SessionRpcUsage<'a> {
5189 /// Gets accumulated usage metrics for the session.
5190 ///
5191 /// Wire method: `session.usage.getMetrics`.
5192 ///
5193 /// # Returns
5194 ///
5195 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
5196 ///
5197 /// <div class="warning">
5198 ///
5199 /// **Experimental.** This API is part of an experimental wire-protocol surface
5200 /// and may change or be removed in future SDK or CLI releases. Pin both the
5201 /// SDK and CLI versions if your code depends on it.
5202 ///
5203 /// </div>
5204 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
5205 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5206 let _value = self
5207 .session
5208 .client()
5209 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
5210 .await?;
5211 Ok(serde_json::from_value(_value)?)
5212 }
5213}
5214
5215/// `session.workspaces.*` RPCs.
5216#[derive(Clone, Copy)]
5217pub struct SessionRpcWorkspaces<'a> {
5218 pub(crate) session: &'a Session,
5219}
5220
5221impl<'a> SessionRpcWorkspaces<'a> {
5222 /// Gets current workspace metadata for the session.
5223 ///
5224 /// Wire method: `session.workspaces.getWorkspace`.
5225 ///
5226 /// # Returns
5227 ///
5228 /// Current workspace metadata for the session, including its absolute filesystem path when available.
5229 ///
5230 /// <div class="warning">
5231 ///
5232 /// **Experimental.** This API is part of an experimental wire-protocol surface
5233 /// and may change or be removed in future SDK or CLI releases. Pin both the
5234 /// SDK and CLI versions if your code depends on it.
5235 ///
5236 /// </div>
5237 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
5238 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5239 let _value = self
5240 .session
5241 .client()
5242 .call(
5243 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
5244 Some(wire_params),
5245 )
5246 .await?;
5247 Ok(serde_json::from_value(_value)?)
5248 }
5249
5250 /// Lists files stored in the session workspace files directory.
5251 ///
5252 /// Wire method: `session.workspaces.listFiles`.
5253 ///
5254 /// # Returns
5255 ///
5256 /// Relative paths of files stored in the session workspace files directory.
5257 ///
5258 /// <div class="warning">
5259 ///
5260 /// **Experimental.** This API is part of an experimental wire-protocol surface
5261 /// and may change or be removed in future SDK or CLI releases. Pin both the
5262 /// SDK and CLI versions if your code depends on it.
5263 ///
5264 /// </div>
5265 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
5266 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5267 let _value = self
5268 .session
5269 .client()
5270 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
5271 .await?;
5272 Ok(serde_json::from_value(_value)?)
5273 }
5274
5275 /// Reads a file from the session workspace files directory.
5276 ///
5277 /// Wire method: `session.workspaces.readFile`.
5278 ///
5279 /// # Parameters
5280 ///
5281 /// * `params` - Relative path of the workspace file to read.
5282 ///
5283 /// # Returns
5284 ///
5285 /// Contents of the requested workspace file as a UTF-8 string.
5286 ///
5287 /// <div class="warning">
5288 ///
5289 /// **Experimental.** This API is part of an experimental wire-protocol surface
5290 /// and may change or be removed in future SDK or CLI releases. Pin both the
5291 /// SDK and CLI versions if your code depends on it.
5292 ///
5293 /// </div>
5294 pub async fn read_file(
5295 &self,
5296 params: WorkspacesReadFileRequest,
5297 ) -> Result<WorkspacesReadFileResult, Error> {
5298 let mut wire_params = serde_json::to_value(params)?;
5299 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5300 let _value = self
5301 .session
5302 .client()
5303 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
5304 .await?;
5305 Ok(serde_json::from_value(_value)?)
5306 }
5307
5308 /// Creates or overwrites a file in the session workspace files directory.
5309 ///
5310 /// Wire method: `session.workspaces.createFile`.
5311 ///
5312 /// # Parameters
5313 ///
5314 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
5315 ///
5316 /// <div class="warning">
5317 ///
5318 /// **Experimental.** This API is part of an experimental wire-protocol surface
5319 /// and may change or be removed in future SDK or CLI releases. Pin both the
5320 /// SDK and CLI versions if your code depends on it.
5321 ///
5322 /// </div>
5323 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
5324 let mut wire_params = serde_json::to_value(params)?;
5325 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5326 let _value = self
5327 .session
5328 .client()
5329 .call(
5330 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
5331 Some(wire_params),
5332 )
5333 .await?;
5334 Ok(())
5335 }
5336
5337 /// Lists workspace checkpoints in chronological order.
5338 ///
5339 /// Wire method: `session.workspaces.listCheckpoints`.
5340 ///
5341 /// # Returns
5342 ///
5343 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
5344 ///
5345 /// <div class="warning">
5346 ///
5347 /// **Experimental.** This API is part of an experimental wire-protocol surface
5348 /// and may change or be removed in future SDK or CLI releases. Pin both the
5349 /// SDK and CLI versions if your code depends on it.
5350 ///
5351 /// </div>
5352 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
5353 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5354 let _value = self
5355 .session
5356 .client()
5357 .call(
5358 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
5359 Some(wire_params),
5360 )
5361 .await?;
5362 Ok(serde_json::from_value(_value)?)
5363 }
5364
5365 /// Reads the content of a workspace checkpoint by number.
5366 ///
5367 /// Wire method: `session.workspaces.readCheckpoint`.
5368 ///
5369 /// # Parameters
5370 ///
5371 /// * `params` - Checkpoint number to read.
5372 ///
5373 /// # Returns
5374 ///
5375 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
5376 ///
5377 /// <div class="warning">
5378 ///
5379 /// **Experimental.** This API is part of an experimental wire-protocol surface
5380 /// and may change or be removed in future SDK or CLI releases. Pin both the
5381 /// SDK and CLI versions if your code depends on it.
5382 ///
5383 /// </div>
5384 pub async fn read_checkpoint(
5385 &self,
5386 params: WorkspacesReadCheckpointRequest,
5387 ) -> Result<WorkspacesReadCheckpointResult, Error> {
5388 let mut wire_params = serde_json::to_value(params)?;
5389 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5390 let _value = self
5391 .session
5392 .client()
5393 .call(
5394 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
5395 Some(wire_params),
5396 )
5397 .await?;
5398 Ok(serde_json::from_value(_value)?)
5399 }
5400
5401 /// Saves pasted content as a UTF-8 file in the session workspace.
5402 ///
5403 /// Wire method: `session.workspaces.saveLargePaste`.
5404 ///
5405 /// # Parameters
5406 ///
5407 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
5408 ///
5409 /// # Returns
5410 ///
5411 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
5412 ///
5413 /// <div class="warning">
5414 ///
5415 /// **Experimental.** This API is part of an experimental wire-protocol surface
5416 /// and may change or be removed in future SDK or CLI releases. Pin both the
5417 /// SDK and CLI versions if your code depends on it.
5418 ///
5419 /// </div>
5420 pub async fn save_large_paste(
5421 &self,
5422 params: WorkspacesSaveLargePasteRequest,
5423 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
5424 let mut wire_params = serde_json::to_value(params)?;
5425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5426 let _value = self
5427 .session
5428 .client()
5429 .call(
5430 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
5431 Some(wire_params),
5432 )
5433 .await?;
5434 Ok(serde_json::from_value(_value)?)
5435 }
5436}