feat(monitoring): dispatch monitoring tasks to desktop via AMQP outbox

Replace SSE /desktop/events with priority AMQP dispatch for monitoring
runs, and add phase1/phase2 infrastructure so desktop workers can lease,
resume, report, skip, and cancel monitoring tasks over the existing
dispatch WebSocket.

- Add monitoring collect outbox worker and phase2 desktop task fields
- Add /desktop/monitoring/tasks/{lease,resume,result,skip,cancel} routes
- Introduce execution-devtools and network-observer on desktop runtime
- Refactor runtime-controller, LoginView, and doubao adapter for the new flow
- Add channelName column to tracking views

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 00:24:21 +08:00
parent 749b6b99cd
commit 4142c53fa6
57 changed files with 7897 additions and 985 deletions
@@ -5,6 +5,7 @@ import (
"strings"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/geo-platform/tenant-api/internal/bootstrap"
"github.com/geo-platform/tenant-api/internal/shared/response"
@@ -16,12 +17,16 @@ type MonitoringHandler struct {
}
type monitoringCollectNowRequest struct {
KeywordID *int64 `json:"keyword_id"`
KeywordID *int64 `json:"keyword_id"`
PlatformIDs []string `json:"platform_ids"`
Preempt *bool `json:"preempt"`
WaitForFirstDispatch *bool `json:"wait_for_first_dispatch"`
TargetClientID *string `json:"target_client_id"`
}
func NewMonitoringHandler(a *bootstrap.App) *MonitoringHandler {
return &MonitoringHandler{
svc: app.NewMonitoringService(a.DB, a.MonitoringDB),
svc: app.NewMonitoringService(a.DB, a.MonitoringDB, a.RabbitMQ, a.Config.MonitoringDispatch, a.Logger),
}
}
@@ -98,7 +103,22 @@ func (h *MonitoringHandler) CollectNow(c *gin.Context) {
return
}
data, svcErr := h.svc.CollectNow(c.Request.Context(), brandID, req.KeywordID)
var targetClientID *uuid.UUID
if req.TargetClientID != nil && strings.TrimSpace(*req.TargetClientID) != "" {
parsed, parseErr := uuid.Parse(strings.TrimSpace(*req.TargetClientID))
if parseErr != nil {
response.Error(c, response.ErrBadRequest(40031, "invalid_target_client_id", "target_client_id must be a uuid"))
return
}
targetClientID = &parsed
}
data, svcErr := h.svc.CollectNow(c.Request.Context(), brandID, req.KeywordID, app.MonitoringCollectNowOptions{
PlatformIDs: req.PlatformIDs,
Preempt: req.Preempt == nil || *req.Preempt,
WaitForFirstDispatch: req.WaitForFirstDispatch != nil && *req.WaitForFirstDispatch,
TargetClientID: targetClientID,
})
if svcErr != nil {
response.Error(c, svcErr)
return