jvserve 2.0.13__py3-none-any.whl → 2.0.16__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 jvserve might be problematic. Click here for more details.
- jvserve/__init__.py +1 -1
- jvserve/lib/agent_interface.py +123 -53
- {jvserve-2.0.13.dist-info → jvserve-2.0.16.dist-info}/METADATA +1 -1
- jvserve-2.0.16.dist-info/RECORD +13 -0
- jvserve-2.0.13.dist-info/RECORD +0 -13
- {jvserve-2.0.13.dist-info → jvserve-2.0.16.dist-info}/WHEEL +0 -0
- {jvserve-2.0.13.dist-info → jvserve-2.0.16.dist-info}/entry_points.txt +0 -0
- {jvserve-2.0.13.dist-info → jvserve-2.0.16.dist-info}/licenses/LICENSE +0 -0
- {jvserve-2.0.13.dist-info → jvserve-2.0.16.dist-info}/top_level.txt +0 -0
jvserve/__init__.py
CHANGED
jvserve/lib/agent_interface.py
CHANGED
|
@@ -160,76 +160,146 @@ class AgentInterface:
|
|
|
160
160
|
return response
|
|
161
161
|
|
|
162
162
|
@staticmethod
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
def get_action_data(agent_id: str, action_label: str) -> dict:
|
|
164
|
+
"""Retrieves the data for a specific action of an agent."""
|
|
165
|
+
|
|
166
|
+
action_data = {}
|
|
167
|
+
ctx = AgentInterface.load_context()
|
|
168
|
+
|
|
169
|
+
if not ctx:
|
|
170
|
+
return {}
|
|
171
|
+
|
|
172
|
+
# TODO : raise error in the event agent id is invalid
|
|
173
|
+
AgentInterface.LOGGER.debug(
|
|
174
|
+
f"attempting to interact with agent {agent_id} with user root {ctx.root}..."
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
try:
|
|
178
|
+
actions = _Jac.spawn_call(
|
|
179
|
+
ctx.entry_node.architype,
|
|
180
|
+
AgentInterface.spawn_walker(
|
|
181
|
+
walker_name="list_actions",
|
|
182
|
+
attributes={"agent_id": agent_id},
|
|
183
|
+
module_name="agent.action.list_actions",
|
|
184
|
+
),
|
|
185
|
+
).actions
|
|
186
|
+
|
|
187
|
+
if actions:
|
|
188
|
+
for action in actions:
|
|
189
|
+
if action.get("label") == action_label:
|
|
190
|
+
action_data = action
|
|
191
|
+
break
|
|
192
|
+
|
|
193
|
+
except Exception as e:
|
|
194
|
+
AgentInterface.EXPIRATION = None
|
|
195
|
+
AgentInterface.LOGGER.error(
|
|
196
|
+
f"an exception occurred: {e}, {traceback.format_exc()}"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
ctx.close()
|
|
200
|
+
return action_data
|
|
201
|
+
|
|
202
|
+
@staticmethod
|
|
203
|
+
def action_walker_exec(
|
|
204
|
+
agent_id: Optional[str] = Form(None), # noqa: B008
|
|
205
|
+
module_root: Optional[str] = Form(None), # noqa: B008
|
|
206
|
+
walker: Optional[str] = Form(None), # noqa: B008
|
|
167
207
|
args: Optional[str] = Form(None), # noqa: B008
|
|
168
208
|
attachments: List[UploadFile] = File(default_factory=list), # noqa: B008
|
|
169
209
|
) -> JSONResponse:
|
|
170
|
-
"""
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
210
|
+
"""
|
|
211
|
+
Execute a named walker exposed by an action within context.
|
|
212
|
+
Capable of handling JSON or file data depending on request.
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
agent_id: ID of the agent
|
|
216
|
+
action: Name of the action
|
|
217
|
+
walker: Name of the walker to execute
|
|
218
|
+
args: JSON string of additional arguments
|
|
219
|
+
attachments: List of uploaded files
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
JSONResponse: Response containing walker output or error message
|
|
223
|
+
"""
|
|
224
|
+
ctx = None
|
|
174
225
|
try:
|
|
226
|
+
# Validate required parameters
|
|
227
|
+
if walker is None or agent_id is None or module_root is None:
|
|
228
|
+
AgentInterface.LOGGER.error("Missing required parameters")
|
|
229
|
+
return JSONResponse(
|
|
230
|
+
status_code=400, # 400 (Bad Request)
|
|
231
|
+
content={"error": "Missing required parameters"},
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# Load execution context
|
|
235
|
+
ctx = AgentInterface.load_context()
|
|
236
|
+
if not ctx:
|
|
237
|
+
AgentInterface.LOGGER.error(f"Unable to execute {walker}")
|
|
238
|
+
return JSONResponse(
|
|
239
|
+
status_code=500,
|
|
240
|
+
content={"error": "Failed to load execution context"},
|
|
241
|
+
)
|
|
175
242
|
|
|
176
|
-
#
|
|
243
|
+
# Prepare attributes
|
|
177
244
|
attributes: Dict[str, Any] = {"agent_id": agent_id}
|
|
178
245
|
|
|
179
|
-
#
|
|
246
|
+
# Parse additional arguments if provided
|
|
180
247
|
if args:
|
|
181
|
-
|
|
248
|
+
try:
|
|
249
|
+
attributes.update(json.loads(args))
|
|
250
|
+
except json.JSONDecodeError as e:
|
|
251
|
+
AgentInterface.LOGGER.error(f"Invalid JSON in args: {e}")
|
|
252
|
+
return JSONResponse(
|
|
253
|
+
status_code=400,
|
|
254
|
+
content={"error": "Invalid JSON in arguments"},
|
|
255
|
+
)
|
|
182
256
|
|
|
183
|
-
#
|
|
257
|
+
# Process uploaded files
|
|
184
258
|
if attachments:
|
|
185
259
|
attributes["files"] = []
|
|
186
260
|
for file in attachments:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
261
|
+
try:
|
|
262
|
+
attributes["files"].append(
|
|
263
|
+
{
|
|
264
|
+
"name": file.filename,
|
|
265
|
+
"type": file.content_type,
|
|
266
|
+
"content": file.file.read(),
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
except Exception as e:
|
|
270
|
+
AgentInterface.LOGGER.error(
|
|
271
|
+
f"Failed to process file {file.filename}: {e}"
|
|
272
|
+
)
|
|
273
|
+
continue # Skip problematic files or return error if critical
|
|
194
274
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
275
|
+
# Execute the walker
|
|
276
|
+
walker_response = _Jac.spawn_call(
|
|
277
|
+
ctx.entry_node.architype,
|
|
278
|
+
AgentInterface.spawn_walker(
|
|
279
|
+
walker_name=walker,
|
|
280
|
+
attributes=attributes,
|
|
281
|
+
module_name=f"{module_root}.{walker}",
|
|
282
|
+
),
|
|
283
|
+
).response
|
|
284
|
+
ctx.close()
|
|
285
|
+
|
|
286
|
+
return walker_response
|
|
200
287
|
|
|
201
288
|
except Exception as e:
|
|
289
|
+
AgentInterface.EXPIRATION = None
|
|
202
290
|
AgentInterface.LOGGER.error(
|
|
203
|
-
f"
|
|
291
|
+
f"Exception occurred: {str(e)}\n{traceback.format_exc()}"
|
|
204
292
|
)
|
|
205
|
-
return JSONResponse(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
AgentInterface.spawn_walker(
|
|
216
|
-
walker_name=walker,
|
|
217
|
-
attributes=attributes,
|
|
218
|
-
module_name=module,
|
|
219
|
-
),
|
|
220
|
-
).response
|
|
221
|
-
|
|
222
|
-
except Exception as e:
|
|
223
|
-
AgentInterface.EXPIRATION = None
|
|
224
|
-
AgentInterface.LOGGER.error(
|
|
225
|
-
f"an exception occurred: {e}, {traceback.format_exc()}"
|
|
226
|
-
)
|
|
227
|
-
else:
|
|
228
|
-
AgentInterface.LOGGER.error(f"unable to execute {walker}")
|
|
229
|
-
|
|
230
|
-
ctx.close()
|
|
231
|
-
|
|
232
|
-
return response
|
|
293
|
+
return JSONResponse(
|
|
294
|
+
status_code=500,
|
|
295
|
+
content={"error": "Internal server error", "details": str(e)},
|
|
296
|
+
)
|
|
297
|
+
finally:
|
|
298
|
+
if ctx:
|
|
299
|
+
try:
|
|
300
|
+
ctx.close()
|
|
301
|
+
except Exception as e:
|
|
302
|
+
AgentInterface.LOGGER.error(f"Error closing context: {str(e)}")
|
|
233
303
|
|
|
234
304
|
class InteractPayload(BaseModel):
|
|
235
305
|
"""Payload for interacting with the agent."""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
jvserve/__init__.py,sha256=pq6aKUL15KaEDAIo2zlj2RtTFVdN-vXUx3UVdOZxOeM,191
|
|
2
|
+
jvserve/cli.py,sha256=NJD4ehtKnhOvsz-vrFh9lz3P4bnxqz-uqTr8QItljZc,8897
|
|
3
|
+
jvserve/lib/__init__.py,sha256=cnzfSHLoTWG9Ygut2nOpDys5aPlQz-m0BSkB-nd7OMs,31
|
|
4
|
+
jvserve/lib/agent_interface.py,sha256=-uewEL_M4cZpZVl0rIOXnVpZI-3O9aGKLljoCgKSW0M,34955
|
|
5
|
+
jvserve/lib/agent_pulse.py,sha256=6hBF6KQYr6Z9Mi_yoWKGfdnW7gg84kK20Slu-bLR_m8,2067
|
|
6
|
+
jvserve/lib/file_interface.py,sha256=sqwTmBnZsVFQUGt7mE1EWA-jHnZlRtBAFeb4Rb_QgQ8,6079
|
|
7
|
+
jvserve/lib/jvlogger.py,sha256=RNiB9PHuBzTvNIQWhxoDgrDlNYA0PYm1SVpvzlqu8mE,4180
|
|
8
|
+
jvserve-2.0.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
9
|
+
jvserve-2.0.16.dist-info/METADATA,sha256=kRy2uTRK7zZBau0hAOt5BunMHO0m2OHHQPUzY9BGUOY,4791
|
|
10
|
+
jvserve-2.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
jvserve-2.0.16.dist-info/entry_points.txt,sha256=HYyg1QXoLs0JRb004L300VeLOZyDLY27ynD1tnTnEN4,35
|
|
12
|
+
jvserve-2.0.16.dist-info/top_level.txt,sha256=afoCXZv-zXNBuhVIvfJGjafXKEiJl_ooy4BtgQwAG4Q,8
|
|
13
|
+
jvserve-2.0.16.dist-info/RECORD,,
|
jvserve-2.0.13.dist-info/RECORD
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
jvserve/__init__.py,sha256=AHR-iejuKB2C8u25HZ1ccXlh6tCaB3MuKVTJz-LZzig,191
|
|
2
|
-
jvserve/cli.py,sha256=NJD4ehtKnhOvsz-vrFh9lz3P4bnxqz-uqTr8QItljZc,8897
|
|
3
|
-
jvserve/lib/__init__.py,sha256=cnzfSHLoTWG9Ygut2nOpDys5aPlQz-m0BSkB-nd7OMs,31
|
|
4
|
-
jvserve/lib/agent_interface.py,sha256=4SHqvySxu08dK2cPoe2TjMKlm11VqM0qDalOKp-tma4,32347
|
|
5
|
-
jvserve/lib/agent_pulse.py,sha256=6hBF6KQYr6Z9Mi_yoWKGfdnW7gg84kK20Slu-bLR_m8,2067
|
|
6
|
-
jvserve/lib/file_interface.py,sha256=sqwTmBnZsVFQUGt7mE1EWA-jHnZlRtBAFeb4Rb_QgQ8,6079
|
|
7
|
-
jvserve/lib/jvlogger.py,sha256=RNiB9PHuBzTvNIQWhxoDgrDlNYA0PYm1SVpvzlqu8mE,4180
|
|
8
|
-
jvserve-2.0.13.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
9
|
-
jvserve-2.0.13.dist-info/METADATA,sha256=8gyJ1EnRbjZDZnOU3F-Y4lq9loXHIGLNCXn3YpPiUzg,4791
|
|
10
|
-
jvserve-2.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
-
jvserve-2.0.13.dist-info/entry_points.txt,sha256=HYyg1QXoLs0JRb004L300VeLOZyDLY27ynD1tnTnEN4,35
|
|
12
|
-
jvserve-2.0.13.dist-info/top_level.txt,sha256=afoCXZv-zXNBuhVIvfJGjafXKEiJl_ooy4BtgQwAG4Q,8
|
|
13
|
-
jvserve-2.0.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|