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
71 lines
2.0 KiB
Go
71 lines
2.0 KiB
Go
package eventstream
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"log/slog"
|
|
"strings"
|
|
"time"
|
|
|
|
collabrunbiz "github.com/tutti-os/tutti/services/tuttid/biz/collabrun"
|
|
)
|
|
|
|
// AgentCollaborationPublisher broadcasts collaboration run lifecycle changes
|
|
// (consult started/settled, fork/delegate/handoff recorded, adoption changes)
|
|
// so GUI surfaces can refresh run accounting without polling. The signature
|
|
// matches the collabrun service Publisher contract: publish failures are
|
|
// logged, never surfaced into the run workflow.
|
|
type AgentCollaborationPublisher struct {
|
|
Service *Service
|
|
Now func() time.Time
|
|
}
|
|
|
|
func (p AgentCollaborationPublisher) PublishCollaborationRunUpdated(workspaceID string, run collabrunbiz.Run) {
|
|
if p.Service == nil {
|
|
return
|
|
}
|
|
workspaceID = strings.TrimSpace(workspaceID)
|
|
if workspaceID == "" || strings.TrimSpace(run.ID) == "" {
|
|
return
|
|
}
|
|
now := time.Now()
|
|
if p.Now != nil {
|
|
now = p.Now()
|
|
}
|
|
payload, err := json.Marshal(agentCollaborationUpdatedPayload{
|
|
WorkspaceID: workspaceID,
|
|
RunID: run.ID,
|
|
Mode: string(run.Mode),
|
|
Status: string(run.Status),
|
|
SourceSessionID: run.SourceSessionID,
|
|
TargetSessionID: run.TargetSessionID,
|
|
ModelPlanID: run.ModelPlanID,
|
|
Model: run.Model,
|
|
TriggerSource: string(run.TriggerSource),
|
|
Adoption: string(run.Adoption),
|
|
OccurredAtUnixMS: now.UnixMilli(),
|
|
})
|
|
if err != nil {
|
|
slog.Warn("agent collaboration updated payload marshal failed",
|
|
"event", "agent.collaboration.updated_publish_failed",
|
|
"workspaceId", workspaceID,
|
|
"runId", run.ID,
|
|
"error", err,
|
|
)
|
|
return
|
|
}
|
|
if err := p.Service.PublishFromServerScoped(
|
|
context.Background(),
|
|
TopicAgentCollaborationUpdated,
|
|
payload,
|
|
EventScope{WorkspaceID: workspaceID},
|
|
); err != nil {
|
|
slog.Warn("agent collaboration updated publish failed",
|
|
"event", "agent.collaboration.updated_publish_failed",
|
|
"workspaceId", workspaceID,
|
|
"runId", run.ID,
|
|
"error", err,
|
|
)
|
|
}
|
|
}
|