core

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RunSnapshotSSEEvent is the canonical snapshot event name for daemon run streams.
	RunSnapshotSSEEvent = "run.snapshot"
	// RunEventSSEEvent is the canonical live event name for daemon run streams.
	RunEventSSEEvent = "run.event"
	// RunHeartbeatSSEEvent is the canonical heartbeat event name for daemon run streams.
	RunHeartbeatSSEEvent = "run.heartbeat"
	// RunOverflowSSEEvent is the canonical overflow event name for daemon run streams.
	RunOverflowSSEEvent = "run.overflow"
)
View Source
const (
	// WorkspaceEventSocketType is the live event message type for daemon workspace sockets.
	WorkspaceEventSocketType = "workspace.event"
	// WorkspaceHeartbeatSocketType is the heartbeat message type for daemon workspace sockets.
	WorkspaceHeartbeatSocketType = "workspace.heartbeat"
	// WorkspaceOverflowSocketType is the overflow message type for daemon workspace sockets.
	WorkspaceOverflowSocketType = "workspace.overflow"
	// WorkspaceErrorSocketType is the error message type for daemon workspace sockets.
	WorkspaceErrorSocketType = "error"
)
View Source
const CookieCSRF = "productize" + "_csrf"

CookieCSRF carries the browser mutation CSRF cookie name.

View Source
const HeaderActiveWorkspaceID = "X-Productize-Workspace-ID"

HeaderActiveWorkspaceID carries the browser-selected active workspace ID.

View Source
const HeaderCSRF = "X-Productize-CSRF-" + "Token"

HeaderCSRF carries the double-submit CSRF header name for browser mutations.

View Source
const HeaderRequestID = "X-Request-Id"

HeaderRequestID is the canonical request ID response header.

Variables

This section is empty.

Functions

func ActiveWorkspaceIDFromContext

func ActiveWorkspaceIDFromContext(ctx context.Context) string

ActiveWorkspaceIDFromContext returns the resolved active workspace ID when available.

func ErrorMiddleware

func ErrorMiddleware() gin.HandlerFunc

ErrorMiddleware converts unhandled Gin errors into the transport error envelope.

func EventAfterCursor

func EventAfterCursor(event events.Event, cursor StreamCursor) bool

EventAfterCursor reports whether an event should be emitted after the given cursor.

func FormatCursor

func FormatCursor(timestamp time.Time, sequence uint64) string

FormatCursor renders the canonical cursor form.

func RegisterRoutes

func RegisterRoutes(router gin.IRouter, handlers *Handlers)

RegisterRoutes registers the shared daemon API routes on the supplied router.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext returns the propagated request ID when available.

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware ensures every request carries a transport request ID.

func RespondError

func RespondError(c *gin.Context, err error)

RespondError writes a transport error response for one request.

func WithActiveWorkspaceID

func WithActiveWorkspaceID(ctx context.Context, workspaceID string) context.Context

WithActiveWorkspaceID returns a child context carrying the resolved active workspace ID.

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID returns a child context carrying the transport request ID.

func WorkspacePathMissingProblem

func WorkspacePathMissingProblem(workspaceID string, rootDir string, err error) error

func WriteSSE

func WriteSSE(writer FlushWriter, msg SSEMessage) error

WriteSSE writes one SSE message with JSON-encoded data.

func WriteWorkspaceSocketMessage

func WriteWorkspaceSocketMessage(
	ctx context.Context,
	conn *websocket.Conn,
	message WorkspaceSocketMessage,
) error

Types

type ArchiveRequest

type ArchiveRequest = contract.WorkflowArchiveRequest

type ArchiveResult

type ArchiveResult = contract.ArchiveResult

type ContentBlock

type ContentBlock = contract.ContentBlock

type ContentBlockType

type ContentBlockType = contract.ContentBlockType

type DaemonDatabaseDiagnostics

type DaemonDatabaseDiagnostics = contract.DaemonDatabaseDiagnostics

type DaemonHealth

type DaemonHealth = contract.DaemonHealth

type DaemonModeCount

type DaemonModeCount = contract.DaemonModeCount

type DaemonReconcileDiagnostics

type DaemonReconcileDiagnostics = contract.DaemonReconcileDiagnostics

type DaemonService

type DaemonService interface {
	Status(context.Context) (DaemonStatus, error)
	Health(context.Context) (DaemonHealth, error)
	Metrics(context.Context) (MetricsPayload, error)
	Stop(context.Context, bool) error
}

DaemonService exposes daemon-wide status, health, metrics, and shutdown control.

type DaemonStatus

type DaemonStatus = contract.DaemonStatus

type ExecRequest

type ExecRequest = contract.ExecRequest

type ExecService

type ExecService interface {
	Start(context.Context, ExecRequest) (Run, error)
}

ExecService exposes ad-hoc daemon-backed exec starts.

type FlushWriter

type FlushWriter interface {
	io.Writer
	http.Flusher
}

FlushWriter is the subset of the response writer needed for streaming.

func PrepareSSE

func PrepareSSE(c *gin.Context) (FlushWriter, error)

PrepareSSE configures one Gin response for server-sent events.

type HandlerConfig

type HandlerConfig struct {
	TransportName                 string
	Logger                        *slog.Logger
	Now                           func() time.Time
	HeartbeatInterval             time.Duration
	StreamDone                    <-chan struct{}
	WorkspaceSocketOriginPatterns []string

	Daemon          DaemonService
	Workspaces      WorkspaceService
	WorkspaceEvents WorkspaceEventService
	Tasks           TaskService
	Reviews         ReviewService
	Runs            RunService
	Sync            SyncService
	Exec            ExecService
}

HandlerConfig wires the shared daemon transport handlers.

type Handlers

type Handlers struct {
	TransportName     string
	Logger            *slog.Logger
	Now               func() time.Time
	HeartbeatInterval time.Duration

	Daemon          DaemonService
	Workspaces      WorkspaceService
	WorkspaceEvents WorkspaceEventService
	Tasks           TaskService
	Reviews         ReviewService
	Runs            RunService
	Sync            SyncService
	Exec            ExecService
	// contains filtered or unexported fields
}

Handlers contains the shared daemon API handler logic used by both transports.

func NewHandlers

func NewHandlers(cfg *HandlerConfig) *Handlers

NewHandlers builds the shared handler set with transport-specific defaults applied.

func (*Handlers) ArchiveTaskWorkflow

func (h *Handlers) ArchiveTaskWorkflow(c *gin.Context)

ArchiveTaskWorkflow archives a completed workflow.

func (*Handlers) CancelRun

func (h *Handlers) CancelRun(c *gin.Context)

CancelRun requests cancellation for one run.

func (*Handlers) Clone

func (h *Handlers) Clone() *Handlers

Clone copies the handler set so each transport can own its runtime state independently.

func (*Handlers) DaemonHealth

func (h *Handlers) DaemonHealth(c *gin.Context)

DaemonHealth returns daemon readiness and degraded-state details.

func (*Handlers) DaemonMetrics

func (h *Handlers) DaemonMetrics(c *gin.Context)

DaemonMetrics returns the daemon metrics in Prometheus text format.

func (*Handlers) DaemonStatus

func (h *Handlers) DaemonStatus(c *gin.Context)

DaemonStatus returns the primary daemon status view.

func (*Handlers) DeleteWorkspace

func (h *Handlers) DeleteWorkspace(c *gin.Context)

DeleteWorkspace unregisters one workspace.

func (*Handlers) FetchReview

func (h *Handlers) FetchReview(c *gin.Context)

FetchReview imports provider feedback into a review round.

func (*Handlers) GetLatestReview

func (h *Handlers) GetLatestReview(c *gin.Context)

GetLatestReview returns the latest review summary for one workflow.

func (*Handlers) GetReviewIssue

func (h *Handlers) GetReviewIssue(c *gin.Context)

GetReviewIssue returns the richer review issue detail payload.

func (*Handlers) GetReviewRound

func (h *Handlers) GetReviewRound(c *gin.Context)

GetReviewRound returns one review round summary.

func (*Handlers) GetRun

func (h *Handlers) GetRun(c *gin.Context)

GetRun returns one run summary.

func (*Handlers) GetRunSnapshot

func (h *Handlers) GetRunSnapshot(c *gin.Context)

GetRunSnapshot returns the attach snapshot for one run.

func (*Handlers) GetRunTranscript

func (h *Handlers) GetRunTranscript(c *gin.Context)

GetRunTranscript returns the canonical structured transcript for one run.

func (*Handlers) GetTaskBoard

func (h *Handlers) GetTaskBoard(c *gin.Context)

GetTaskBoard returns the workflow task-board read model.

func (*Handlers) GetTaskItemDetail

func (h *Handlers) GetTaskItemDetail(c *gin.Context)

GetTaskItemDetail returns the richer workflow task detail payload.

func (*Handlers) GetTaskWorkflow

func (h *Handlers) GetTaskWorkflow(c *gin.Context)

GetTaskWorkflow returns the richer workflow overview payload.

func (*Handlers) GetWorkflowMemory

func (h *Handlers) GetWorkflowMemory(c *gin.Context)

GetWorkflowMemory returns the memory index for one workflow.

func (*Handlers) GetWorkflowMemoryFile

func (h *Handlers) GetWorkflowMemoryFile(c *gin.Context)

GetWorkflowMemoryFile returns one workflow memory document by opaque daemon-issued ID.

func (*Handlers) GetWorkflowSpec

func (h *Handlers) GetWorkflowSpec(c *gin.Context)

GetWorkflowSpec returns the workflow PRD, TechSpec, and ADR documents.

func (*Handlers) GetWorkspace

func (h *Handlers) GetWorkspace(c *gin.Context)

GetWorkspace returns one workspace by ID or normalized path key.

func (*Handlers) ListReviewIssues

func (h *Handlers) ListReviewIssues(c *gin.Context)

ListReviewIssues returns one review round issue list.

func (*Handlers) ListRunEvents

func (h *Handlers) ListRunEvents(c *gin.Context)

ListRunEvents pages through persisted run events.

func (*Handlers) ListRuns

func (h *Handlers) ListRuns(c *gin.Context)

ListRuns lists runs across workspaces or for one workspace.

func (*Handlers) ListTaskItems

func (h *Handlers) ListTaskItems(c *gin.Context)

ListTaskItems lists parsed task items for one workflow.

func (*Handlers) ListTaskWorkflows

func (h *Handlers) ListTaskWorkflows(c *gin.Context)

ListTaskWorkflows lists task workflows for one workspace.

func (*Handlers) ListWorkspaces

func (h *Handlers) ListWorkspaces(c *gin.Context)

ListWorkspaces lists registered workspaces.

func (*Handlers) RegisterWorkspace

func (h *Handlers) RegisterWorkspace(c *gin.Context)

RegisterWorkspace registers a workspace explicitly.

func (*Handlers) ResolveWorkspace

func (h *Handlers) ResolveWorkspace(c *gin.Context)

ResolveWorkspace resolves or lazily registers a workspace path.

func (*Handlers) SetStreamDone

func (h *Handlers) SetStreamDone(done <-chan struct{})

SetStreamDone updates the transport shutdown bridge used by streaming handlers.

func (*Handlers) StartExecRun

func (h *Handlers) StartExecRun(c *gin.Context)

StartExecRun starts one ad-hoc daemon-backed exec run.

func (*Handlers) StartReviewRun

func (h *Handlers) StartReviewRun(c *gin.Context)

StartReviewRun starts one review-fix run.

func (*Handlers) StartReviewWatch

func (h *Handlers) StartReviewWatch(c *gin.Context)

StartReviewWatch starts one daemon-owned review-watch parent run.

func (*Handlers) StartTaskRun

func (h *Handlers) StartTaskRun(c *gin.Context)

StartTaskRun starts one task workflow run.

func (*Handlers) StopDaemon

func (h *Handlers) StopDaemon(c *gin.Context)

StopDaemon requests a graceful daemon shutdown.

func (*Handlers) StreamRun

func (h *Handlers) StreamRun(c *gin.Context)

StreamRun streams live run events with cursor resume, heartbeat, and overflow semantics.

func (*Handlers) StreamWorkspaceSocket

func (h *Handlers) StreamWorkspaceSocket(c *gin.Context)

StreamWorkspaceSocket streams workspace-scoped invalidation messages for the browser UI.

func (*Handlers) SyncWorkflow

func (h *Handlers) SyncWorkflow(c *gin.Context)

SyncWorkflow runs explicit daemon reconciliation for a workspace or workflow.

func (*Handlers) SyncWorkspaces

func (h *Handlers) SyncWorkspaces(c *gin.Context)

SyncWorkspaces refreshes registered workspace filesystem state and artifact mirrors.

func (*Handlers) UpdateWorkspace

func (h *Handlers) UpdateWorkspace(c *gin.Context)

UpdateWorkspace updates mutable workspace metadata.

func (*Handlers) ValidateTaskWorkflow

func (h *Handlers) ValidateTaskWorkflow(c *gin.Context)

ValidateTaskWorkflow validates task files for one workflow.

type HealthDetail

type HealthDetail = contract.HealthDetail

type HeartbeatPayload

type HeartbeatPayload = contract.HeartbeatPayload

type MarkdownDocument

type MarkdownDocument struct {
	ID        string          `json:"id"`
	Kind      string          `json:"kind"`
	Title     string          `json:"title"`
	UpdatedAt time.Time       `json:"updated_at"`
	Markdown  string          `json:"markdown"`
	Metadata  json.RawMessage `json:"metadata,omitempty"`
}

MarkdownDocument is the normalized daemon-served markdown payload.

type MetricsPayload

type MetricsPayload struct {
	Body        string
	ContentType string
}

MetricsPayload carries pre-rendered metrics text.

type OverflowPayload

type OverflowPayload = contract.OverflowPayload

type Problem

type Problem = contract.Problem

func NewProblem

func NewProblem(status int, code string, message string, details map[string]any, err error) *Problem

type ReviewDetailPayload

type ReviewDetailPayload struct {
	Workspace   Workspace         `json:"workspace"`
	Workflow    WorkflowSummary   `json:"workflow"`
	Round       ReviewRound       `json:"round"`
	Issue       ReviewIssueDetail `json:"issue"`
	Document    MarkdownDocument  `json:"document"`
	RelatedRuns []Run             `json:"related_runs,omitempty"`
}

ReviewDetailPayload captures the richer review issue detail read model.

type ReviewFetchRequest

type ReviewFetchRequest = contract.ReviewFetchRequest

type ReviewFetchResult

type ReviewFetchResult = contract.ReviewFetchResult

type ReviewIssue

type ReviewIssue = contract.ReviewIssue

type ReviewIssueDetail

type ReviewIssueDetail struct {
	ID          string    `json:"id"`
	IssueNumber int       `json:"issue_number"`
	Severity    string    `json:"severity"`
	Status      string    `json:"status"`
	UpdatedAt   time.Time `json:"updated_at"`
}

ReviewIssueDetail captures the detail metadata for one review issue.

type ReviewRound

type ReviewRound = contract.ReviewRound

type ReviewRunRequest

type ReviewRunRequest = contract.ReviewRunRequest

type ReviewService

ReviewService exposes review round state, review detail reads, and review-fix run starts.

type ReviewSummary

type ReviewSummary = contract.ReviewSummary

type ReviewWatchRequest

type ReviewWatchRequest = contract.ReviewWatchRequest

type ReviewWatchResponse

type ReviewWatchResponse = contract.RunResponse

type Run

type Run = contract.Run

type RunArtifactSyncEntry

type RunArtifactSyncEntry struct {
	Sequence     uint64    `json:"sequence"`
	RelativePath string    `json:"relative_path"`
	ChangeKind   string    `json:"change_kind"`
	Checksum     string    `json:"checksum,omitempty"`
	SyncedAt     time.Time `json:"synced_at"`
}

RunArtifactSyncEntry is one artifact sync history row from the run database.

type RunDetailPayload

type RunDetailPayload struct {
	Run          Run                    `json:"run"`
	Snapshot     RunSnapshot            `json:"snapshot"`
	JobCounts    RunJobCounts           `json:"job_counts"`
	Runtime      RunRuntimeSummary      `json:"runtime"`
	Timeline     []events.Event         `json:"timeline,omitempty"`
	ArtifactSync []RunArtifactSyncEntry `json:"artifact_sync,omitempty"`
}

RunDetailPayload captures the richer run detail read model exposed to the browser.

type RunEventPage

type RunEventPage = contract.RunEventPage

type RunEventPageQuery

type RunEventPageQuery = contract.RunEventPageQuery

type RunJobCounts

type RunJobCounts struct {
	Queued    int `json:"queued"`
	Running   int `json:"running"`
	Retrying  int `json:"retrying"`
	Completed int `json:"completed"`
	Failed    int `json:"failed"`
	Canceled  int `json:"canceled"`
}

RunJobCounts summarizes run jobs by status.

type RunJobState

type RunJobState = contract.RunJobState

type RunJobSummary

type RunJobSummary = contract.RunJobSummary

type RunListQuery

type RunListQuery = contract.RunListQuery

type RunRuntimeSummary

type RunRuntimeSummary struct {
	IDEs              []string `json:"ides,omitempty"`
	Models            []string `json:"models,omitempty"`
	ReasoningEfforts  []string `json:"reasoning_efforts,omitempty"`
	AccessModes       []string `json:"access_modes,omitempty"`
	PresentationModes []string `json:"presentation_modes,omitempty"`
}

RunRuntimeSummary captures the distinct runtime settings observed in one run snapshot.

type RunService

RunService exposes run snapshots, rich run detail, pagination, streaming, and cancellation.

type RunShutdownState

type RunShutdownState = contract.RunShutdownState

type RunSnapshot

type RunSnapshot = contract.RunSnapshot

type RunStream

type RunStream interface {
	Events() <-chan RunStreamItem
	Errors() <-chan error
	Close() error
}

RunStream is the live run event subscription surfaced to the transport layer.

type RunStreamItem

type RunStreamItem struct {
	Event    *events.Event
	Overflow *RunStreamOverflow
}

RunStreamItem carries one live stream delivery or an overflow notice.

type RunStreamOverflow

type RunStreamOverflow struct {
	Reason string
}

RunStreamOverflow notifies the transport that the client must reconnect from the last cursor.

type RunTranscript

type RunTranscript = contract.RunTranscript

type RunTranscriptMessage

type RunTranscriptMessage = contract.RunTranscriptMessage

type RunUIMessage

type RunUIMessage = contract.RunUIMessage

type RunUIMessagePart

type RunUIMessagePart = contract.RunUIMessagePart

type SSEMessage

type SSEMessage = contract.SSEMessage

func EventMessage

func EventMessage(event events.Event) SSEMessage

EventMessage builds the canonical live-event SSE frame.

func HeartbeatMessage

func HeartbeatMessage(runID string, cursor StreamCursor, now time.Time) SSEMessage

HeartbeatMessage builds the canonical heartbeat SSE event.

func OverflowMessage

func OverflowMessage(runID string, cursor StreamCursor, now time.Time, reason string) SSEMessage

OverflowMessage builds the canonical overflow SSE event.

type SessionAvailableCommand

type SessionAvailableCommand = contract.SessionAvailableCommand

type SessionEntry

type SessionEntry = contract.SessionEntry

type SessionEntryKind

type SessionEntryKind = contract.SessionEntryKind

type SessionMetaState

type SessionMetaState = contract.SessionMetaState

type SessionPlanEntry

type SessionPlanEntry = contract.SessionPlanEntry

type SessionPlanState

type SessionPlanState = contract.SessionPlanState

type SessionStatus

type SessionStatus = contract.SessionStatus

type SessionViewSnapshot

type SessionViewSnapshot = contract.SessionViewSnapshot

type StreamCursor

type StreamCursor = contract.StreamCursor

func CursorFromEvent

func CursorFromEvent(event events.Event) StreamCursor

CursorFromEvent builds the canonical cursor for one persisted event.

func ParseCursor

func ParseCursor(raw string) (StreamCursor, error)

ParseCursor parses a Last-Event-ID or pagination cursor.

type SyncRequest

type SyncRequest = contract.SyncRequest

type SyncResult

type SyncResult = contract.SyncResult

type SyncService

type SyncService interface {
	Sync(context.Context, SyncRequest) (SyncResult, error)
}

SyncService exposes explicit workflow reconciliation.

type TaskBoardPayload

type TaskBoardPayload struct {
	Workspace  Workspace          `json:"workspace"`
	Workflow   WorkflowSummary    `json:"workflow"`
	TaskCounts WorkflowTaskCounts `json:"task_counts"`
	Lanes      []TaskLane         `json:"lanes,omitempty"`
}

TaskBoardPayload captures the workflow task-board read model.

type TaskCard

type TaskCard struct {
	TaskNumber int       `json:"task_number"`
	TaskID     string    `json:"task_id"`
	Title      string    `json:"title"`
	Status     string    `json:"status"`
	Type       string    `json:"type"`
	DependsOn  []string  `json:"depends_on,omitempty"`
	UpdatedAt  time.Time `json:"updated_at"`
}

TaskCard is the compact task row used by board and detail reads.

type TaskDetailPayload

type TaskDetailPayload struct {
	Workspace         Workspace             `json:"workspace"`
	Workflow          WorkflowSummary       `json:"workflow"`
	Task              TaskCard              `json:"task"`
	Document          MarkdownDocument      `json:"document"`
	MemoryEntries     []WorkflowMemoryEntry `json:"memory_entries,omitempty"`
	RelatedRuns       []Run                 `json:"related_runs,omitempty"`
	LiveTailAvailable bool                  `json:"live_tail_available"`
}

TaskDetailPayload captures the richer workflow task detail read model.

type TaskItem

type TaskItem = contract.TaskItem

type TaskLane

type TaskLane struct {
	Status string     `json:"status"`
	Title  string     `json:"title"`
	Items  []TaskCard `json:"items,omitempty"`
}

TaskLane groups task cards under one normalized status lane.

type TaskRunRequest

type TaskRunRequest = contract.TaskRunRequest

type TaskService

TaskService exposes workflow summary, rich read-model, validation, and run-start surfaces.

type ToolCallState

type ToolCallState = contract.ToolCallState

type TransportError

type TransportError = contract.TransportError

type ValidationSuccess

type ValidationSuccess = contract.ValidationSuccess

type WorkflowMemoryEntry

type WorkflowMemoryEntry struct {
	FileID      string    `json:"file_id"`
	DisplayPath string    `json:"display_path"`
	Kind        string    `json:"kind"`
	Title       string    `json:"title"`
	SizeBytes   int64     `json:"size_bytes"`
	UpdatedAt   time.Time `json:"updated_at"`
}

WorkflowMemoryEntry describes one memory file without exposing raw filesystem paths.

type WorkflowMemoryIndex

type WorkflowMemoryIndex struct {
	Workspace Workspace             `json:"workspace"`
	Workflow  WorkflowSummary       `json:"workflow"`
	Entries   []WorkflowMemoryEntry `json:"entries,omitempty"`
}

WorkflowMemoryIndex lists workflow memory files using opaque daemon-issued identifiers.

type WorkflowOverviewPayload

type WorkflowOverviewPayload struct {
	Workspace       Workspace          `json:"workspace"`
	Workflow        WorkflowSummary    `json:"workflow"`
	TaskCounts      WorkflowTaskCounts `json:"task_counts"`
	LatestReview    *ReviewSummary     `json:"latest_review,omitempty"`
	RecentRuns      []Run              `json:"recent_runs,omitempty"`
	ArchiveEligible bool               `json:"archive_eligible"`
	ArchiveReason   string             `json:"archive_reason,omitempty"`
}

WorkflowOverviewPayload is the richer workflow summary aggregate used by browser reads.

type WorkflowSpecDocument

type WorkflowSpecDocument struct {
	Workspace Workspace          `json:"workspace"`
	Workflow  WorkflowSummary    `json:"workflow"`
	PRD       *MarkdownDocument  `json:"prd,omitempty"`
	TechSpec  *MarkdownDocument  `json:"techspec,omitempty"`
	ADRs      []MarkdownDocument `json:"adrs,omitempty"`
}

WorkflowSpecDocument captures the canonical workflow spec artifacts.

type WorkflowSummary

type WorkflowSummary = contract.WorkflowSummary

type WorkflowTaskCounts

type WorkflowTaskCounts = contract.WorkflowTaskCounts

WorkflowTaskCounts summarizes task progress for one workflow.

type Workspace

type Workspace = contract.Workspace

type WorkspaceEvent

type WorkspaceEvent struct {
	Seq          uint64             `json:"seq"`
	TS           time.Time          `json:"ts"`
	WorkspaceID  string             `json:"workspace_id"`
	WorkflowID   *string            `json:"workflow_id,omitempty"`
	WorkflowSlug string             `json:"workflow_slug,omitempty"`
	RunID        string             `json:"run_id,omitempty"`
	Mode         string             `json:"mode,omitempty"`
	Status       string             `json:"status,omitempty"`
	Kind         WorkspaceEventKind `json:"kind"`
	Paths        []string           `json:"paths,omitempty"`
}

WorkspaceEvent is a lightweight daemon-owned invalidation event for one workspace.

type WorkspaceEventKind

type WorkspaceEventKind string
const (
	WorkspaceEventKindRunCreated            WorkspaceEventKind = "run.created"
	WorkspaceEventKindRunStatusChanged      WorkspaceEventKind = "run.status_changed"
	WorkspaceEventKindRunTerminal           WorkspaceEventKind = "run.terminal"
	WorkspaceEventKindWorkflowSyncCompleted WorkspaceEventKind = "workflow.sync_completed"
	WorkspaceEventKindArtifactChanged       WorkspaceEventKind = "artifact.changed"
)

type WorkspaceEventService

type WorkspaceEventService interface {
	OpenWorkspaceStream(context.Context, string) (WorkspaceEventStream, error)
}

WorkspaceEventService exposes workspace-scoped browser event streams.

type WorkspaceEventStream

type WorkspaceEventStream interface {
	Events() <-chan WorkspaceStreamItem
	Errors() <-chan error
	Close() error
}

WorkspaceEventStream is the live workspace event subscription surfaced to the transport layer.

type WorkspaceRegisterResult

type WorkspaceRegisterResult = contract.WorkspaceRegisterResult

type WorkspaceService

WorkspaceService exposes workspace registration and lookup.

type WorkspaceSocketHeartbeatPayload

type WorkspaceSocketHeartbeatPayload struct {
	WorkspaceID string    `json:"workspace_id"`
	TS          time.Time `json:"ts"`
}

WorkspaceSocketHeartbeatPayload carries a workspace socket heartbeat.

type WorkspaceSocketMessage

type WorkspaceSocketMessage struct {
	Type    string          `json:"type"`
	ID      string          `json:"id,omitempty"`
	Payload json.RawMessage `json:"payload"`
}

WorkspaceSocketMessage is the JSON envelope sent over workspace WebSocket connections.

func WorkspaceErrorSocketMessage

func WorkspaceErrorSocketMessage(payload TransportError) (WorkspaceSocketMessage, error)

func WorkspaceEventSocketMessage

func WorkspaceEventSocketMessage(event WorkspaceEvent) (WorkspaceSocketMessage, error)

func WorkspaceHeartbeatSocketMessage

func WorkspaceHeartbeatSocketMessage(workspaceID string, now time.Time) (WorkspaceSocketMessage, error)

func WorkspaceOverflowSocketMessage

func WorkspaceOverflowSocketMessage(
	workspaceID string,
	now time.Time,
	reason string,
) (WorkspaceSocketMessage, error)

type WorkspaceSocketOverflowPayload

type WorkspaceSocketOverflowPayload struct {
	WorkspaceID string    `json:"workspace_id"`
	Reason      string    `json:"reason"`
	TS          time.Time `json:"ts"`
}

WorkspaceSocketOverflowPayload notifies a browser that workspace events were dropped.

type WorkspaceStreamItem

type WorkspaceStreamItem struct {
	Event    *WorkspaceEvent
	Overflow *WorkspaceStreamOverflow
}

WorkspaceStreamItem carries one workspace event delivery or an overflow notice.

type WorkspaceStreamOverflow

type WorkspaceStreamOverflow struct {
	Reason string `json:"reason"`
}

WorkspaceStreamOverflow notifies the browser that workspace events were dropped.

type WorkspaceSyncResult

type WorkspaceSyncResult = contract.WorkspaceSyncResult

type WorkspaceUpdateInput

type WorkspaceUpdateInput = contract.WorkspaceUpdateInput

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL