vv_agent/sdk/client/sessions/
defaults.rs1use std::path::PathBuf;
2
3use crate::sdk::session::AgentSession;
4use crate::types::Metadata;
5
6use super::super::AgentSDKClient;
7use super::base::{
8 create_agent_session, create_agent_session_with_id, create_agent_session_with_id_and_workspace,
9 create_agent_session_with_id_and_workspace_and_shared_state,
10 create_agent_session_with_shared_state, create_agent_session_with_workspace,
11 create_agent_session_with_workspace_and_shared_state,
12};
13
14impl AgentSDKClient {
15 pub fn create_default_session(&self) -> Result<AgentSession, String> {
16 let (name, definition) = self.default_or_only_agent(
17 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
18 "Multiple agents configured. Call create_agent_session_by_name(name) with one of:",
19 )?;
20 Ok(create_agent_session(self, name, definition))
21 }
22
23 pub fn create_default_session_with_workspace(
24 &self,
25 workspace: impl Into<PathBuf>,
26 ) -> Result<AgentSession, String> {
27 let (name, definition) = self.default_or_only_agent(
28 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
29 "Multiple agents configured. Call create_agent_session_by_name_in_workspace(name, workspace) with one of:",
30 )?;
31 Ok(create_agent_session_with_workspace(
32 self, name, definition, workspace,
33 ))
34 }
35
36 pub fn create_default_session_with_id(
37 &self,
38 session_id: impl Into<String>,
39 ) -> Result<AgentSession, String> {
40 let (name, definition) = self.default_or_only_agent(
41 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
42 "Multiple agents configured. Call create_agent_session_by_name_with_id(name, session_id) with one of:",
43 )?;
44 Ok(create_agent_session_with_id(
45 self, name, definition, session_id,
46 ))
47 }
48
49 pub fn create_default_session_with_id_and_workspace(
50 &self,
51 session_id: impl Into<String>,
52 workspace: impl Into<PathBuf>,
53 ) -> Result<AgentSession, String> {
54 let (name, definition) = self.default_or_only_agent(
55 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
56 "Multiple agents configured. Call create_agent_session_by_name_with_id_and_workspace(name, session_id, workspace) with one of:",
57 )?;
58 Ok(create_agent_session_with_id_and_workspace(
59 self, name, definition, session_id, workspace,
60 ))
61 }
62
63 pub fn create_default_session_with_workspace_and_shared_state(
64 &self,
65 workspace: impl Into<PathBuf>,
66 shared_state: Metadata,
67 ) -> Result<AgentSession, String> {
68 let (name, definition) = self.default_or_only_agent(
69 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
70 "Multiple agents configured. Call create_agent_session_by_name_in_workspace(name, workspace) with one of:",
71 )?;
72 Ok(create_agent_session_with_workspace_and_shared_state(
73 self,
74 name,
75 definition,
76 workspace,
77 shared_state,
78 ))
79 }
80
81 pub fn create_default_session_with_id_workspace_and_shared_state(
82 &self,
83 session_id: impl Into<String>,
84 workspace: impl Into<PathBuf>,
85 shared_state: Metadata,
86 ) -> Result<AgentSession, String> {
87 let (name, definition) = self.default_or_only_agent(
88 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
89 "Multiple agents configured. Call create_agent_session_by_name_with_id_and_workspace(name, session_id, workspace) with one of:",
90 )?;
91 Ok(create_agent_session_with_id_and_workspace_and_shared_state(
92 self,
93 name,
94 definition,
95 session_id,
96 workspace,
97 shared_state,
98 ))
99 }
100
101 pub fn create_default_session_with_shared_state(
102 &self,
103 shared_state: Metadata,
104 ) -> Result<AgentSession, String> {
105 let (name, definition) = self.default_or_only_agent(
106 "No agent configured. Call create_session_with_agent(...) or register named agents first.",
107 "Multiple agents configured. Call create_agent_session_by_name_with_shared_state(name, shared_state) with one of:",
108 )?;
109 Ok(create_agent_session_with_shared_state(
110 self,
111 name,
112 definition,
113 shared_state,
114 ))
115 }
116}