solace-agent-mesh 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agents/base_agent_component.py +101 -71
- solace_agent_mesh/assets/web-visualizer/assets/{index-C5awueeJ.js → index-DnDr1pnu.js} +33 -33
- solace_agent_mesh/assets/web-visualizer/index.html +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/config_portal/backend/server.py +41 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-a-zJ6rLx.js +46 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{manifest-c92a7808.js → manifest-44c41103.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/index.html +1 -1
- solace_agent_mesh/services/history_service/history_providers/sql_history_provider.py +3 -3
- {solace_agent_mesh-0.2.2.dist-info → solace_agent_mesh-0.2.4.dist-info}/METADATA +9 -5
- {solace_agent_mesh-0.2.2.dist-info → solace_agent_mesh-0.2.4.dist-info}/RECORD +14 -14
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-b13CSm84.js +0 -42
- {solace_agent_mesh-0.2.2.dist-info → solace_agent_mesh-0.2.4.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-0.2.2.dist-info → solace_agent_mesh-0.2.4.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-0.2.2.dist-info → solace_agent_mesh-0.2.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -109,86 +109,86 @@ class BaseAgentComponent(LLMServiceComponentBase, ABC):
|
|
|
109
109
|
"actions": self.get_actions_summary(),
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
def
|
|
113
|
-
"""Invoke the component"""
|
|
114
|
-
action_name = data.get("action_name")
|
|
115
|
-
action_response = None
|
|
116
|
-
file_service = FileService()
|
|
112
|
+
def _handle_action_validation(self, action_name, data):
|
|
117
113
|
if not action_name:
|
|
118
114
|
log.error("Action name not provided. Data: %s", json.dumps(data))
|
|
119
|
-
|
|
115
|
+
return ActionResponse(
|
|
120
116
|
message="Internal error: Action name not provided. Please try again",
|
|
121
117
|
)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
else:
|
|
132
|
-
resolved_params = data.get("action_params", {}).copy()
|
|
133
|
-
try:
|
|
134
|
-
session_id = (message.get_user_properties() or {}).get("session_id")
|
|
135
|
-
resolved_params = recursive_file_resolver(
|
|
136
|
-
resolved_params,
|
|
137
|
-
resolver=file_service.resolve_all_resolvable_urls,
|
|
138
|
-
session_id=session_id,
|
|
139
|
-
)
|
|
140
|
-
except Exception as e:
|
|
141
|
-
log.error(
|
|
142
|
-
"Error resolving file service URLs: %s. Data: %s",
|
|
143
|
-
str(e),
|
|
144
|
-
json.dumps(data),
|
|
145
|
-
exc_info=True,
|
|
146
|
-
)
|
|
147
|
-
action_response = ActionResponse(
|
|
148
|
-
message=f"Error resolving file URLs. Details: {str(e)}",
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
middleware_service = MiddlewareService()
|
|
152
|
-
if middleware_service.get("base_agent_filter")(message.user_properties or {}, action):
|
|
153
|
-
try:
|
|
154
|
-
meta = {
|
|
155
|
-
"session_id": session_id,
|
|
156
|
-
}
|
|
157
|
-
action_response = action.invoke(resolved_params, meta)
|
|
158
|
-
except Exception as e:
|
|
159
|
-
|
|
160
|
-
error_message = (
|
|
161
|
-
f"Error invoking action {action_name} "
|
|
162
|
-
f"in agent {self.info.get('agent_name', 'Unknown')}: \n\n"
|
|
163
|
-
f"Exception name: {type(e).__name__}\n"
|
|
164
|
-
f"Exception info: {str(e)}\n"
|
|
165
|
-
f"Stack trace: {traceback.format_exc()}\n\n"
|
|
166
|
-
f"Data: {json.dumps(data)}"
|
|
167
|
-
)
|
|
168
|
-
log.error(error_message)
|
|
169
|
-
action_response = ActionResponse(
|
|
170
|
-
message=f"Internal error: {type(e).__name__} - Error invoking action. Details: {str(e)}",
|
|
171
|
-
error_info=ErrorInfo(
|
|
172
|
-
error_message=error_message,
|
|
173
|
-
),
|
|
174
|
-
)
|
|
175
|
-
else:
|
|
176
|
-
log.warning(
|
|
177
|
-
"Unauthorized access attempt for action %s. Data: %s",
|
|
178
|
-
action_name,
|
|
179
|
-
json.dumps(data),
|
|
180
|
-
)
|
|
181
|
-
action_response = ActionResponse(
|
|
182
|
-
message="Unauthorized: You don't have permission to perform this action.",
|
|
183
|
-
)
|
|
118
|
+
action = self.action_list.get_action(action_name)
|
|
119
|
+
if not action:
|
|
120
|
+
log.error(
|
|
121
|
+
"Action not found: %s. Data: %s", action_name, json.dumps(data)
|
|
122
|
+
)
|
|
123
|
+
return ActionResponse(
|
|
124
|
+
message="Internal error: Action not found. Please try again",
|
|
125
|
+
)
|
|
126
|
+
return action
|
|
184
127
|
|
|
128
|
+
def _resolve_action_parameters(self, params, session_id, data, file_service):
|
|
129
|
+
try:
|
|
130
|
+
resolved_params = recursive_file_resolver(
|
|
131
|
+
params,
|
|
132
|
+
resolver=file_service.resolve_all_resolvable_urls,
|
|
133
|
+
session_id=session_id,
|
|
134
|
+
)
|
|
135
|
+
return resolved_params, None
|
|
136
|
+
except Exception as e:
|
|
137
|
+
log.error(
|
|
138
|
+
"Error resolving file service URLs: %s. Data: %s",
|
|
139
|
+
str(e),
|
|
140
|
+
json.dumps(data),
|
|
141
|
+
exc_info=True,
|
|
142
|
+
)
|
|
143
|
+
return params, ActionResponse(
|
|
144
|
+
message=f"Error resolving file URLs. Details: {str(e)}",
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
def _execute_action(self, action, resolved_params, user_properties, action_name, data):
|
|
148
|
+
session_id = user_properties.get("session_id")
|
|
149
|
+
identity = user_properties.get("identity")
|
|
150
|
+
middleware_service = MiddlewareService()
|
|
151
|
+
|
|
152
|
+
if not middleware_service.get("base_agent_filter")(user_properties, action):
|
|
153
|
+
log.warning(
|
|
154
|
+
"Unauthorized access attempt for action %s. Data: %s",
|
|
155
|
+
action_name,
|
|
156
|
+
json.dumps(data),
|
|
157
|
+
)
|
|
158
|
+
return ActionResponse(
|
|
159
|
+
message="Unauthorized: You don't have permission to perform this action.",
|
|
160
|
+
)
|
|
161
|
+
try:
|
|
162
|
+
meta = {
|
|
163
|
+
"session_id": session_id,
|
|
164
|
+
"identity": identity,
|
|
165
|
+
}
|
|
166
|
+
return action.invoke(resolved_params, meta)
|
|
167
|
+
except Exception as e:
|
|
168
|
+
error_message = (
|
|
169
|
+
f"Error invoking action {action_name} "
|
|
170
|
+
f"in agent {self.info.get('agent_name', 'Unknown')}: \n\n"
|
|
171
|
+
f"Exception name: {type(e).__name__}\n"
|
|
172
|
+
f"Exception info: {str(e)}\n"
|
|
173
|
+
f"Stack trace: {traceback.format_exc()}\n\n"
|
|
174
|
+
f"Data: {json.dumps(data)}"
|
|
175
|
+
)
|
|
176
|
+
log.error(error_message)
|
|
177
|
+
return ActionResponse(
|
|
178
|
+
message=f"Internal error: {type(e).__name__} - Error invoking action. Details: {str(e)}",
|
|
179
|
+
error_info=ErrorInfo(
|
|
180
|
+
error_message=error_message,
|
|
181
|
+
),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def _prepare_response_payload(self, action_response, action_name, data):
|
|
185
185
|
action_response.action_list_id = data.get("action_list_id")
|
|
186
186
|
action_response.action_idx = data.get("action_idx")
|
|
187
187
|
action_response.action_name = action_name
|
|
188
188
|
action_response.action_params = data.get("action_params", {})
|
|
189
189
|
action_response.originator = data.get("originator", ORCHESTRATOR_COMPONENT_NAME)
|
|
190
190
|
try:
|
|
191
|
-
|
|
191
|
+
return action_response.to_dict()
|
|
192
192
|
except Exception as e:
|
|
193
193
|
log.error(
|
|
194
194
|
"Error after action %s in converting action response to dict: %s. Data: %s",
|
|
@@ -197,13 +197,43 @@ class BaseAgentComponent(LLMServiceComponentBase, ABC):
|
|
|
197
197
|
json.dumps(data),
|
|
198
198
|
exc_info=True,
|
|
199
199
|
)
|
|
200
|
-
|
|
200
|
+
return {
|
|
201
201
|
"message": "Internal error: Error converting action response to dict",
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
def invoke(self, message, data):
|
|
205
|
+
"""Invoke the component"""
|
|
206
|
+
action_name = data.get("action_name")
|
|
207
|
+
file_service = FileService()
|
|
208
|
+
|
|
209
|
+
validation_result = self._handle_action_validation(action_name, data)
|
|
210
|
+
if isinstance(validation_result, ActionResponse):
|
|
211
|
+
action_response_dict = self._prepare_response_payload(validation_result, action_name, data)
|
|
212
|
+
response_topic = f"{os.getenv('SOLACE_AGENT_MESH_NAMESPACE')}solace-agent-mesh/v1/actionResponse/agent/{self.info['agent_name']}/{action_name or 'unknown'}"
|
|
213
|
+
return {"payload": action_response_dict, "topic": response_topic}
|
|
214
|
+
|
|
215
|
+
action = validation_result
|
|
216
|
+
|
|
217
|
+
resolved_params = data.get("action_params", {}).copy()
|
|
218
|
+
user_properties = message.get_user_properties() or {}
|
|
219
|
+
session_id = user_properties.get("session_id")
|
|
220
|
+
|
|
221
|
+
resolved_params, file_error_response = self._resolve_action_parameters(
|
|
222
|
+
resolved_params, session_id, data, file_service
|
|
223
|
+
)
|
|
224
|
+
if file_error_response:
|
|
225
|
+
action_response_dict = self._prepare_response_payload(file_error_response, action_name, data)
|
|
226
|
+
response_topic = f"{os.getenv('SOLACE_AGENT_MESH_NAMESPACE')}solace-agent-mesh/v1/actionResponse/agent/{self.info['agent_name']}/{action_name}"
|
|
227
|
+
return {"payload": action_response_dict, "topic": response_topic}
|
|
228
|
+
|
|
229
|
+
action_response = self._execute_action(
|
|
230
|
+
action, resolved_params, user_properties, action_name, data
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
action_response_dict = self._prepare_response_payload(action_response, action_name, data)
|
|
234
|
+
|
|
204
235
|
# Construct the response topic
|
|
205
236
|
response_topic = f"{os.getenv('SOLACE_AGENT_MESH_NAMESPACE')}solace-agent-mesh/v1/actionResponse/agent/{self.info['agent_name']}/{action_name}"
|
|
206
|
-
|
|
207
237
|
return {"payload": action_response_dict, "topic": response_topic}
|
|
208
238
|
|
|
209
239
|
def handle_timer_event(self, timer_data):
|