awaken_runtime/runtime/agent_runtime/
run_request.rs1use crate::inbox::{InboxReceiver, InboxSender};
4use awaken_contract::contract::inference::InferenceOverride;
5use awaken_contract::contract::message::Message;
6use awaken_contract::contract::storage::RunRequestOrigin;
7use awaken_contract::contract::suspension::ToolCallResume;
8use awaken_contract::contract::tool::ToolDescriptor;
9use awaken_contract::contract::tool_intercept::{AdapterKind, RunMode};
10
11pub struct RunInbox {
13 pub sender: InboxSender,
14 pub receiver: InboxReceiver,
15}
16
17pub struct RunRequest {
19 pub messages: Vec<Message>,
21 pub messages_already_persisted: bool,
27 pub thread_id: String,
29 pub agent_id: Option<String>,
32 pub overrides: Option<InferenceOverride>,
34 pub decisions: Vec<(String, ToolCallResume)>,
36 pub frontend_tools: Vec<ToolDescriptor>,
38 pub origin: RunRequestOrigin,
40 pub run_mode: RunMode,
42 pub adapter: AdapterKind,
44 pub parent_run_id: Option<String>,
46 pub parent_thread_id: Option<String>,
48 pub continue_run_id: Option<String>,
50 pub run_id_hint: Option<String>,
52 pub dispatch_id_hint: Option<String>,
54 pub dispatch_id: Option<String>,
56 pub session_id: Option<String>,
58 pub transport_request_id: Option<String>,
60 pub run_inbox: Option<RunInbox>,
62}
63
64impl RunRequest {
65 pub fn new(thread_id: impl Into<String>, messages: Vec<Message>) -> Self {
67 Self {
68 messages,
69 messages_already_persisted: false,
70 thread_id: thread_id.into(),
71 agent_id: None,
72 overrides: None,
73 decisions: Vec::new(),
74 frontend_tools: Vec::new(),
75 origin: RunRequestOrigin::User,
76 run_mode: RunMode::Foreground,
77 adapter: AdapterKind::Internal,
78 parent_run_id: None,
79 parent_thread_id: None,
80 continue_run_id: None,
81 run_id_hint: None,
82 dispatch_id_hint: None,
83 dispatch_id: None,
84 session_id: None,
85 transport_request_id: None,
86 run_inbox: None,
87 }
88 }
89
90 #[must_use]
91 pub fn with_agent_id(mut self, agent_id: impl Into<String>) -> Self {
92 self.agent_id = Some(agent_id.into());
93 self
94 }
95
96 #[must_use]
97 pub fn with_overrides(mut self, overrides: InferenceOverride) -> Self {
98 self.overrides = Some(overrides);
99 self
100 }
101
102 #[must_use]
103 pub fn with_decisions(mut self, decisions: Vec<(String, ToolCallResume)>) -> Self {
104 self.decisions = decisions;
105 self
106 }
107
108 #[must_use]
109 pub fn with_frontend_tools(mut self, tools: Vec<ToolDescriptor>) -> Self {
110 self.frontend_tools = tools;
111 self
112 }
113
114 #[must_use]
115 pub fn with_origin(mut self, origin: RunRequestOrigin) -> Self {
116 self.origin = origin;
117 self
118 }
119
120 #[must_use]
121 pub fn with_run_mode(mut self, run_mode: RunMode) -> Self {
122 self.run_mode = run_mode;
123 self
124 }
125
126 #[must_use]
127 pub fn with_adapter(mut self, adapter: AdapterKind) -> Self {
128 self.adapter = adapter;
129 self
130 }
131
132 #[must_use]
133 pub fn with_parent_run_id(mut self, parent_run_id: impl Into<String>) -> Self {
134 self.parent_run_id = Some(parent_run_id.into());
135 self
136 }
137
138 #[must_use]
139 pub fn with_parent_thread_id(mut self, parent_thread_id: impl Into<String>) -> Self {
140 self.parent_thread_id = Some(parent_thread_id.into());
141 self
142 }
143
144 #[must_use]
145 pub fn with_continue_run_id(mut self, continue_run_id: impl Into<String>) -> Self {
146 self.continue_run_id = Some(continue_run_id.into());
147 self
148 }
149
150 #[must_use]
151 pub fn with_run_id_hint(mut self, run_id_hint: impl Into<String>) -> Self {
152 self.run_id_hint = Some(run_id_hint.into());
153 self
154 }
155
156 #[must_use]
157 pub fn with_dispatch_id_hint(mut self, dispatch_id_hint: impl Into<String>) -> Self {
158 self.dispatch_id_hint = Some(dispatch_id_hint.into());
159 self
160 }
161
162 #[must_use]
163 pub fn with_trace_dispatch_id(mut self, dispatch_id: impl Into<String>) -> Self {
164 self.dispatch_id = Some(dispatch_id.into());
165 self
166 }
167
168 #[must_use]
169 pub fn with_dispatch_id(mut self, dispatch_id: impl Into<String>) -> Self {
170 self.dispatch_id = Some(dispatch_id.into());
171 self
172 }
173
174 #[must_use]
175 pub fn with_session_id(mut self, session_id: impl Into<String>) -> Self {
176 self.session_id = Some(session_id.into());
177 self
178 }
179
180 #[must_use]
181 pub fn with_transport_request_id(mut self, transport_request_id: impl Into<String>) -> Self {
182 self.transport_request_id = Some(transport_request_id.into());
183 self
184 }
185
186 #[must_use]
187 pub fn with_inbox(mut self, sender: InboxSender, receiver: InboxReceiver) -> Self {
188 self.run_inbox = Some(RunInbox { sender, receiver });
189 self
190 }
191
192 #[must_use]
193 pub fn with_messages_already_persisted(mut self, value: bool) -> Self {
194 self.messages_already_persisted = value;
195 self
196 }
197}