Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package agentstatus
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/tutti-os/tutti/services/tuttid/biz/agentanalytics"
|
|
agentnoderesult "github.com/tutti-os/tutti/services/tuttid/service/reporter/events/agent/node_result"
|
|
)
|
|
|
|
type providerSetupNodeResultInput struct {
|
|
Error error
|
|
Node string
|
|
Provider string
|
|
Result RunActionResult
|
|
StartedAt time.Time
|
|
Status string
|
|
}
|
|
|
|
func (s Service) reportProviderSetupNodeResult(ctx context.Context, input providerSetupNodeResultInput) {
|
|
if s.AnalyticsReporter == nil {
|
|
return
|
|
}
|
|
status := strings.TrimSpace(input.Status)
|
|
if status == "" {
|
|
if input.Error != nil || input.Result.Status == RunActionFailed {
|
|
status = "failure"
|
|
} else {
|
|
status = "success"
|
|
}
|
|
}
|
|
errorMessage := ""
|
|
if input.Error != nil {
|
|
errorMessage = strings.TrimSpace(input.Error.Error())
|
|
} else if status == "failure" {
|
|
errorMessage = strings.TrimSpace(firstNonBlank(input.Result.Message, input.Result.ReasonCode, "Agent provider setup failed"))
|
|
}
|
|
var durationMS *int64
|
|
if !input.StartedAt.IsZero() {
|
|
elapsed := s.now().Sub(input.StartedAt).Milliseconds()
|
|
durationMS = &elapsed
|
|
}
|
|
agentnoderesult.Track(ctx, s.AnalyticsReporter, agentnoderesult.BuildParams(agentnoderesult.NodeResultInput{
|
|
DurationMS: durationMS,
|
|
ErrorCode: providerSetupErrorCode(input.Result.ReasonCode, input.Error),
|
|
ErrorMessage: errorMessage,
|
|
Flow: "provider_setup",
|
|
Node: input.Node,
|
|
Provider: input.Provider,
|
|
Status: status,
|
|
}))
|
|
}
|
|
|
|
func providerSetupErrorCode(reasonCode string, err error) string {
|
|
if err != nil {
|
|
return agentanalytics.ErrorCodeInstallFailed
|
|
}
|
|
switch strings.TrimSpace(reasonCode) {
|
|
case "":
|
|
return agentanalytics.ErrorCodeNone
|
|
case "install_timed_out":
|
|
return agentanalytics.ErrorCodeInstallTimeout
|
|
case "install_canceled":
|
|
return agentanalytics.ErrorCodeInstallCanceled
|
|
case "post_install_probe_failed":
|
|
return agentanalytics.ErrorCodeInstallProbeFailed
|
|
default:
|
|
return agentanalytics.ErrorCodeInstallFailed
|
|
}
|
|
}
|