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
40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package eventstream
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
|
|
eventprotocol "github.com/tutti-os/tutti/services/tuttid/api/events/generated"
|
|
workflowbiz "github.com/tutti-os/tutti/services/tuttid/biz/workspaceworkflow"
|
|
)
|
|
|
|
type WorkspaceWorkflowPublisher struct {
|
|
Service *Service
|
|
}
|
|
|
|
func (p WorkspaceWorkflowPublisher) PublishWorkspaceWorkflowUpdated(ctx context.Context, update workflowbiz.Update) error {
|
|
if p.Service == nil {
|
|
return nil
|
|
}
|
|
update.WorkspaceID = strings.TrimSpace(update.WorkspaceID)
|
|
update.WorkflowID = strings.TrimSpace(update.WorkflowID)
|
|
update.SourceSessionID = strings.TrimSpace(update.SourceSessionID)
|
|
update.CheckpointID = strings.TrimSpace(update.CheckpointID)
|
|
update.ChangeKind = workflowbiz.ChangeKind(strings.TrimSpace(string(update.ChangeKind)))
|
|
if update.WorkspaceID == "" || update.WorkflowID == "" || update.SourceSessionID == "" || update.CheckpointID == "" || update.ChangeKind == "" {
|
|
return nil
|
|
}
|
|
payload, err := json.Marshal(eventprotocol.WorkspaceWorkflowUpdatedPayload{
|
|
WorkflowId: update.WorkflowID,
|
|
SourceSessionId: update.SourceSessionID,
|
|
CheckpointId: update.CheckpointID,
|
|
ChangeKind: string(update.ChangeKind),
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("marshal workspace workflow updated payload: %w", err)
|
|
}
|
|
return p.Service.PublishFromServerScoped(ctx, TopicWorkspaceWorkflowUpdated, payload, EventScope{WorkspaceID: update.WorkspaceID})
|
|
}
|