@@ -34,6 +34,15 @@ AllSpark-edge-server/
3434├── keys/ (SSL certificates)
3535├── third-party/ (Local frontend dependencies)
3636├── uploads/ (Upload directory, auto-created)
37+ │ └── agent_responses/ (Agent analysis results)
38+ │ └── Anomaly_YYYY-MM-DD/
39+ │ └── HHMMSS_<uuid>/
40+ │ ├── response.json (Full AgentResponse as JSON)
41+ │ ├── summary.txt (Human-readable text summary)
42+ │ ├── request.json (Original AnomalyRequest as JSON)
43+ │ ├── session_info.txt (ADK session lookup info)
44+ │ ├── video_clips/ (Video clip(s) for this anomaly)
45+ │ └── machine_anomaly_data/ (Machine/sensor anomaly data)
3746├── node/ (Node.js server implementation)
3847└── python/ (Python server implementation)
3948```
@@ -94,6 +103,56 @@ node server.js
94103websocat --insecure wss://localhost:8080
95104```
96105
106+ ## Agent Service
107+
108+ The edge server includes an agentic analysis pipeline that sends anomaly data (video clips, MQTT logs, sensor readings)
109+ to the [ AllSpark Agentic Framework] ( ../allspark-agentic-framework ) for AI-powered root cause analysis.
110+
111+ ### Submitting an Anomaly for Analysis
112+
113+ ``` bash
114+ cd python
115+ python tests/submit_anomaly_to_edge.py \
116+ --clip-path /path/to/anomaly_clip_20260413_120000.mp4 \
117+ --anomaly-time 2026-04-13T12:00:00 \
118+ --error " missed expected message" \
119+ --expected-topic allspark/anomaly_detected
120+ ```
121+
122+ The timestamp is auto-derived from the clip filename if ` --anomaly-time ` is omitted.
123+
124+ ### Agent Response Storage Layout
125+
126+ Responses are stored under ` uploads/agent_responses/ ` (configurable via ` agentResponsePath ` in ` config.json ` ):
127+
128+ ```
129+ uploads/agent_responses/
130+ └── Anomaly_2026-04-13/
131+ └── 120000_a3f9b2/
132+ ├── response.json ← full AgentResponse (raw agent output + metadata)
133+ ├── summary.txt ← human-readable text summary
134+ ├── request.json ← original AnomalyRequest sent to the agent
135+ ├── session_info.txt ← ADK session ID and web UI lookup instructions
136+ ├── video_clips/ ← video clip(s) associated with this anomaly
137+ └── machine_anomaly_data/ ← machine/sensor data files for this anomaly
138+ ```
139+
140+ ### POST /api/agent/analyze
141+
142+ ``` json
143+ {
144+ "clip_path" : " anomaly_clip_20260413_120000.mp4" ,
145+ "anomaly_time" : " 2026-04-13T12:00:00" ,
146+ "log_path" : " /path/to/mqtt_trace.log" ,
147+ "clip_start_time" : " 2026-04-13T11:59:30" ,
148+ "error" : " missed expected message" ,
149+ "expected_topic" : " allspark/anomaly_detected" ,
150+ "mqtt_clip_messages" : [],
151+ "video_storage_path" : " " ,
152+ "extra_metadata" : {}
153+ }
154+ ```
155+
97156## API Reference
98157
99158See [ docs/endpoints.md] ( docs/endpoints.md ) for the full REST API and WebSocket protocol.
0 commit comments