contract

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: 11 Imported by: 0

Documentation

Overview

Package contract defines the canonical daemon transport contract shared by handlers, clients, SSE helpers, and public run readers.

Index

Constants

View Source
const (
	DefaultHeartbeatInterval = 15 * time.Second
	HeartbeatGapTolerance    = 45 * time.Second
)

Variables

View Source
var RouteInventory = []RouteSpec{
	{
		Method:       http.MethodGet,
		Path:         "/api/daemon/status",
		ResponseType: "DaemonStatusResponse",
		TimeoutClass: TimeoutProbe,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/daemon/health",
		ResponseType: "DaemonHealthResponse",
		TimeoutClass: TimeoutProbe,
	},
	{Method: http.MethodGet, Path: "/api/daemon/metrics", ResponseType: "text/plain", TimeoutClass: TimeoutRead},
	{
		Method:       http.MethodPost,
		Path:         "/api/daemon/stop",
		ResponseType: "MutationAcceptedResponse",
		TimeoutClass: TimeoutMutate,
	},
	{Method: http.MethodPost, Path: "/api/workspaces", ResponseType: "WorkspaceResponse", TimeoutClass: TimeoutMutate},
	{Method: http.MethodGet, Path: "/api/workspaces", ResponseType: "WorkspaceListResponse", TimeoutClass: TimeoutRead},
	{
		Method:       http.MethodPost,
		Path:         "/api/workspaces/sync",
		ResponseType: "WorkspaceSyncResult",
		TimeoutClass: TimeoutLongMutate,
	},
	{Method: http.MethodGet, Path: "/api/workspaces/:id", ResponseType: "WorkspaceResponse", TimeoutClass: TimeoutRead},
	{Method: http.MethodGet, Path: "/api/workspaces/:id/ws", ResponseType: "websocket", TimeoutClass: TimeoutStream},
	{
		Method:       http.MethodPatch,
		Path:         "/api/workspaces/:id",
		ResponseType: "WorkspaceResponse",
		TimeoutClass: TimeoutMutate,
	},
	{
		Method:       http.MethodDelete,
		Path:         "/api/workspaces/:id",
		ResponseType: "MutationAcceptedResponse",
		TimeoutClass: TimeoutMutate,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/workspaces/resolve",
		ResponseType: "WorkspaceResponse",
		TimeoutClass: TimeoutRead,
	},
	{Method: http.MethodGet, Path: "/api/tasks", ResponseType: "TaskWorkflowListResponse", TimeoutClass: TimeoutRead},
	{Method: http.MethodGet, Path: "/api/tasks/:slug", ResponseType: "TaskWorkflowResponse", TimeoutClass: TimeoutRead},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/spec",
		ResponseType: "WorkflowSpecDocument",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/memory",
		ResponseType: "WorkflowMemoryIndex",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/memory/files/:file_id",
		ResponseType: "MarkdownDocument",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/board",
		ResponseType: "TaskBoardPayload",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/items",
		ResponseType: "TaskItemsResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/tasks/:slug/items/:task_id",
		ResponseType: "TaskDetailPayload",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/tasks/:slug/validate",
		ResponseType: "ValidationResponse",
		TimeoutClass: TimeoutMutate,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/tasks/:slug/runs",
		ResponseType: "RunResponse",
		TimeoutClass: TimeoutLongMutate,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/tasks/:slug/archive",
		ResponseType: "ArchiveResponse",
		TimeoutClass: TimeoutMutate,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/reviews/:slug/fetch",
		ResponseType: "ReviewFetchResponse",
		TimeoutClass: TimeoutLongMutate,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/reviews/:slug/watch",
		ResponseType: "RunResponse",
		TimeoutClass: TimeoutLongMutate,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/reviews/:slug",
		ResponseType: "ReviewSummaryResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/reviews/:slug/rounds/:round",
		ResponseType: "ReviewRoundResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/reviews/:slug/rounds/:round/issues",
		ResponseType: "ReviewIssuesResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/reviews/:slug/rounds/:round/issues/:issue_id",
		ResponseType: "ReviewDetailPayload",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodPost,
		Path:         "/api/reviews/:slug/rounds/:round/runs",
		ResponseType: "RunResponse",
		TimeoutClass: TimeoutLongMutate,
	},
	{Method: http.MethodGet, Path: "/api/runs", ResponseType: "RunListResponse", TimeoutClass: TimeoutRead},
	{Method: http.MethodGet, Path: "/api/runs/:run_id", ResponseType: "RunResponse", TimeoutClass: TimeoutRead},
	{
		Method:       http.MethodGet,
		Path:         "/api/runs/:run_id/snapshot",
		ResponseType: "RunSnapshotResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/runs/:run_id/transcript",
		ResponseType: "RunTranscriptResponse",
		TimeoutClass: TimeoutRead,
	},
	{
		Method:       http.MethodGet,
		Path:         "/api/runs/:run_id/events",
		ResponseType: "RunEventPageResponse",
		TimeoutClass: TimeoutRead,
	},
	{Method: http.MethodGet, Path: "/api/runs/:run_id/stream", ResponseType: "sse", TimeoutClass: TimeoutStream},
	{
		Method:       http.MethodPost,
		Path:         "/api/runs/:run_id/cancel",
		ResponseType: "MutationAcceptedResponse",
		TimeoutClass: TimeoutMutate,
	},
	{Method: http.MethodPost, Path: "/api/sync", ResponseType: "SyncResponse", TimeoutClass: TimeoutLongMutate},
	{Method: http.MethodPost, Path: "/api/exec", ResponseType: "RunResponse", TimeoutClass: TimeoutLongMutate},
}
View Source
var RunCompatibilityNotes = []CompatibilityNote{
	{
		Surface: "RunSnapshotResponse",
		StableJSONFields: []string{
			"run",
			"jobs",
			"transcript",
			"usage",
			"shutdown",
			"incomplete",
			"incomplete_reasons",
			"next_cursor",
		},
		AdapterRequiredFor: []string{
			"renaming or re-nesting top-level snapshot fields",
			"changing cursor encoding away from RFC3339Nano|zero-padded-sequence",
		},
		Notes: []string{
			"`next_cursor` stays top-level and string-encoded even though `RunSnapshot.NextCursor` is not JSON-backed",
			"additive fields are allowed, but existing fields must remain stable for downstream readers",
		},
	},
	{
		Surface: "RunEventPageResponse",
		StableJSONFields: []string{
			"events",
			"next_cursor",
			"has_more",
		},
		AdapterRequiredFor: []string{
			"changing pagination cursor encoding",
			"wrapping event records in a new container shape",
		},
		Notes: []string{
			"`events` remains a direct array of canonical `pkg/productize/events.Event` records",
		},
	},
	{
		Surface: "pkg/productize/runs",
		StableJSONFields: []string{
			"run",
			"jobs",
			"incomplete",
			"incomplete_reasons",
			"next_cursor",
		},
		AdapterRequiredFor: []string{
			"removing snapshot job summaries used to infer IDE/model data",
			"changing run summary field names such as `run_id`, `status`, or `presentation_mode`",
		},
		Notes: []string{
			"public run-reader consumers currently rely on snapshot compatibility and must tolerate additive fields like `usage`, `shutdown`, `incomplete`, and `incomplete_reasons`",
		},
	},
}

RunCompatibilityNotes captures the current daemon run-oriented wire surfaces that downstream readers depend on remaining stable.

Functions

func DefaultCodeForStatus

func DefaultCodeForStatus(status int) string

func DefaultTimeout

func DefaultTimeout(class TimeoutClass) time.Duration

func ErrorCodeForStatus

func ErrorCodeForStatus(status int, err error) string

func ErrorDetails

func ErrorDetails(err error, fallback map[string]any) map[string]any

func EventAfterCursor

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

func FormatCursor

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

func FormatCursorPointer

func FormatCursorPointer(cursor *StreamCursor) string

func MessageForStatus

func MessageForStatus(status int, err error, maskInternal bool) string

Types

type ArchiveResponse

type ArchiveResponse = ArchiveResult

type ArchiveResult

type ArchiveResult struct {
	Archived             bool       `json:"archived"`
	ArchivedAt           *time.Time `json:"archived_at,omitempty"`
	Forced               bool       `json:"forced,omitempty"`
	CompletedTasks       int        `json:"completed_tasks,omitempty"`
	ResolvedReviewIssues int        `json:"resolved_review_issues,omitempty"`
}

type CompatibilityNote

type CompatibilityNote struct {
	Surface            string
	StableJSONFields   []string
	AdapterRequiredFor []string
	Notes              []string
}

CompatibilityNote documents one stable daemon transport surface and the categories of changes that would require a compatibility adapter.

type ContentBlock

type ContentBlock struct {
	Type ContentBlockType `json:"type"`
	Data json.RawMessage  `json:"-"`
}

func (ContentBlock) MarshalJSON

func (b ContentBlock) MarshalJSON() ([]byte, error)

func (*ContentBlock) UnmarshalJSON

func (b *ContentBlock) UnmarshalJSON(data []byte) error

type ContentBlockType

type ContentBlockType string

type DaemonDatabaseDiagnostics

type DaemonDatabaseDiagnostics struct {
	GlobalBytes int64 `json:"global_bytes,omitempty"`
	RunDBBytes  int64 `json:"run_db_bytes,omitempty"`
}

type DaemonHealth

type DaemonHealth struct {
	Ready               bool                       `json:"ready"`
	Degraded            bool                       `json:"degraded,omitempty"`
	StartedAt           time.Time                  `json:"started_at,omitempty"`
	UptimeSeconds       int64                      `json:"uptime_seconds,omitempty"`
	ActiveRunCount      int                        `json:"active_run_count,omitempty"`
	ActiveRunsByMode    []DaemonModeCount          `json:"active_runs_by_mode,omitempty"`
	WorkspaceCount      int                        `json:"workspace_count,omitempty"`
	IntegrityIssueCount int                        `json:"integrity_issue_count,omitempty"`
	Databases           DaemonDatabaseDiagnostics  `json:"databases,omitempty"`
	Reconcile           DaemonReconcileDiagnostics `json:"reconcile,omitempty"`
	Details             []HealthDetail             `json:"details,omitempty"`
}

type DaemonHealthResponse

type DaemonHealthResponse struct {
	Health DaemonHealth `json:"health"`
}

type DaemonModeCount

type DaemonModeCount struct {
	Mode  string `json:"mode"`
	Count int    `json:"count"`
}

type DaemonReconcileDiagnostics

type DaemonReconcileDiagnostics struct {
	ReconciledRuns     int    `json:"reconciled_runs,omitempty"`
	CrashEventAppended int    `json:"crash_event_appended,omitempty"`
	CrashEventMissing  int    `json:"crash_event_missing,omitempty"`
	LastRunID          string `json:"last_run_id,omitempty"`
}

type DaemonStatus

type DaemonStatus struct {
	PID            int       `json:"pid"`
	Version        string    `json:"version,omitempty"`
	StartedAt      time.Time `json:"started_at"`
	SocketPath     string    `json:"socket_path,omitempty"`
	ActiveRunCount int       `json:"active_run_count"`
	WorkspaceCount int       `json:"workspace_count"`
}

type DaemonStatusResponse

type DaemonStatusResponse struct {
	Daemon DaemonStatus `json:"daemon"`
}

type ErrorCode

type ErrorCode string
const (
	CodeInvalidRequest        ErrorCode = "invalid_request"
	CodeValidationError       ErrorCode = "validation_error"
	CodeNotFound              ErrorCode = "not_found"
	CodeConflict              ErrorCode = "conflict"
	CodeServiceUnavailable    ErrorCode = "service_unavailable"
	CodeInternalError         ErrorCode = "internal_error"
	CodeSchemaTooNew          ErrorCode = "schema_too_new"
	CodeDaemonNotReady        ErrorCode = "daemon_not_ready"
	CodeDaemonActiveRuns      ErrorCode = "daemon_active_runs"
	CodeWorkspaceRequired     ErrorCode = "workspace_required"
	CodePathRequired          ErrorCode = "path_required"
	CodeNameRequired          ErrorCode = "name_required"
	CodeRoundInvalid          ErrorCode = "round_invalid"
	CodeLimitInvalid          ErrorCode = "limit_invalid"
	CodeInvalidCursor         ErrorCode = "invalid_cursor"
	CodeSyncTargetRequired    ErrorCode = "sync_target_required"
	CodeForceInvalid          ErrorCode = "force_invalid"
	CodeWorkflowForceRequired ErrorCode = "workflow_force_required"
	CodeWorkspacePathNeeded   ErrorCode = "workspace_path_required"
	CodePromptRequired        ErrorCode = "prompt_required"
	CodeStreamUnavailable     ErrorCode = "stream_unavailable"
)

type ExecRequest

type ExecRequest struct {
	WorkspacePath    string          `json:"workspace_path"`
	Prompt           string          `json:"prompt"`
	PresentationMode string          `json:"presentation_mode,omitempty"`
	RuntimeOverrides json.RawMessage `json:"runtime_overrides,omitempty"`
}

type HealthDetail

type HealthDetail struct {
	Code     string `json:"code"`
	Message  string `json:"message"`
	Severity string `json:"severity,omitempty"`
}

type HeartbeatPayload

type HeartbeatPayload struct {
	RunID  string    `json:"run_id"`
	Cursor string    `json:"cursor,omitempty"`
	TS     time.Time `json:"ts"`
}

type MutationAcceptedResponse

type MutationAcceptedResponse struct {
	Accepted bool `json:"accepted"`
}

type OverflowPayload

type OverflowPayload struct {
	RunID  string    `json:"run_id"`
	Cursor string    `json:"cursor,omitempty"`
	Reason string    `json:"reason,omitempty"`
	TS     time.Time `json:"ts"`
}

type Problem

type Problem struct {
	Status  int
	Code    string
	Message string
	Details map[string]any
	Err     error
}

func NewProblem

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

func (*Problem) Error

func (p *Problem) Error() string

func (*Problem) Unwrap

func (p *Problem) Unwrap() error

type ReviewFetchRequest

type ReviewFetchRequest struct {
	Workspace string `json:"workspace"`
	Provider  string `json:"provider,omitempty"`
	PRRef     string `json:"pr_ref,omitempty"`
	Round     *int   `json:"round,omitempty"`
}

type ReviewFetchResponse

type ReviewFetchResponse struct {
	Review ReviewSummary `json:"review"`
}

type ReviewFetchResult

type ReviewFetchResult struct {
	Summary ReviewSummary
	Created bool
}

type ReviewIssue

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

type ReviewIssuesResponse

type ReviewIssuesResponse struct {
	Issues []ReviewIssue `json:"issues"`
}

type ReviewRound

type ReviewRound struct {
	ID              string    `json:"id"`
	WorkflowSlug    string    `json:"workflow_slug"`
	RoundNumber     int       `json:"round_number"`
	Provider        string    `json:"provider,omitempty"`
	PRRef           string    `json:"pr_ref,omitempty"`
	ResolvedCount   int       `json:"resolved_count"`
	UnresolvedCount int       `json:"unresolved_count"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type ReviewRoundResponse

type ReviewRoundResponse struct {
	Round ReviewRound `json:"round"`
}

type ReviewRunRequest

type ReviewRunRequest struct {
	Workspace        string          `json:"workspace"`
	PresentationMode string          `json:"presentation_mode,omitempty"`
	RuntimeOverrides json.RawMessage `json:"runtime_overrides,omitempty"`
	Batching         json.RawMessage `json:"batching,omitempty"`
}

type ReviewSummary

type ReviewSummary struct {
	WorkflowSlug    string    `json:"workflow_slug"`
	RoundNumber     int       `json:"round_number"`
	Provider        string    `json:"provider,omitempty"`
	PRRef           string    `json:"pr_ref,omitempty"`
	ResolvedCount   int       `json:"resolved_count"`
	UnresolvedCount int       `json:"unresolved_count"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type ReviewSummaryResponse

type ReviewSummaryResponse struct {
	Review ReviewSummary `json:"review"`
}

type ReviewWatchRequest

type ReviewWatchRequest struct {
	Workspace        string          `json:"workspace"`
	Provider         string          `json:"provider,omitempty"`
	PRRef            string          `json:"pr_ref"`
	UntilClean       bool            `json:"until_clean,omitempty"`
	MaxRounds        int             `json:"max_rounds,omitempty"`
	AutoPush         bool            `json:"auto_push,omitempty"`
	PushRemote       string          `json:"push_remote,omitempty"`
	PushBranch       string          `json:"push_branch,omitempty"`
	PollInterval     string          `json:"poll_interval,omitempty"`
	ReviewTimeout    string          `json:"review_timeout,omitempty"`
	QuietPeriod      string          `json:"quiet_period,omitempty"`
	RuntimeOverrides json.RawMessage `json:"runtime_overrides,omitempty"`
	Batching         json.RawMessage `json:"batching,omitempty"`
}

type RouteSpec

type RouteSpec struct {
	Method       string
	Path         string
	ResponseType string
	TimeoutClass TimeoutClass
}

func FindRoute

func FindRoute(method string, requestPath string) (RouteSpec, bool)

type Run

type Run struct {
	RunID            string     `json:"run_id"`
	WorkspaceID      string     `json:"workspace_id"`
	WorkflowID       *string    `json:"workflow_id,omitempty"`
	WorkflowSlug     string     `json:"workflow_slug,omitempty"`
	ParentRunID      string     `json:"parent_run_id,omitempty"`
	Mode             string     `json:"mode"`
	Status           string     `json:"status"`
	PresentationMode string     `json:"presentation_mode"`
	StartedAt        time.Time  `json:"started_at"`
	EndedAt          *time.Time `json:"ended_at,omitempty"`
	ErrorText        string     `json:"error_text,omitempty"`
	RequestID        string     `json:"request_id,omitempty"`
}

type RunEventPage

type RunEventPage struct {
	Events     []events.Event
	NextCursor *StreamCursor
	HasMore    bool
}

type RunEventPageQuery

type RunEventPageQuery struct {
	After StreamCursor
	Limit int
}

type RunEventPageResponse

type RunEventPageResponse struct {
	Events     []events.Event `json:"events"`
	NextCursor string         `json:"next_cursor,omitempty"`
	HasMore    bool           `json:"has_more"`
}

func RunEventPageResponseFromPage

func RunEventPageResponseFromPage(page RunEventPage) RunEventPageResponse

func (RunEventPageResponse) Decode

func (r RunEventPageResponse) Decode() (RunEventPage, error)

type RunJobState

type RunJobState struct {
	Index     int            `json:"index"`
	JobID     string         `json:"job_id"`
	TaskID    string         `json:"task_id,omitempty"`
	Status    string         `json:"status"`
	AgentName string         `json:"agent_name,omitempty"`
	Summary   *RunJobSummary `json:"summary,omitempty"`
	UpdatedAt time.Time      `json:"updated_at"`
}

type RunJobSummary

type RunJobSummary struct {
	Index           int                 `json:"index"`
	CodeFile        string              `json:"code_file,omitempty"`
	CodeFiles       []string            `json:"code_files,omitempty"`
	Issues          int                 `json:"issues,omitempty"`
	TaskTitle       string              `json:"task_title,omitempty"`
	TaskType        string              `json:"task_type,omitempty"`
	SafeName        string              `json:"safe_name,omitempty"`
	IDE             string              `json:"ide,omitempty"`
	Model           string              `json:"model,omitempty"`
	ReasoningEffort string              `json:"reasoning_effort,omitempty"`
	AccessMode      string              `json:"access_mode,omitempty"`
	OutLog          string              `json:"out_log,omitempty"`
	ErrLog          string              `json:"err_log,omitempty"`
	Attempt         int                 `json:"attempt,omitempty"`
	MaxAttempts     int                 `json:"max_attempts,omitempty"`
	RetryReason     string              `json:"retry_reason,omitempty"`
	ExitCode        int                 `json:"exit_code,omitempty"`
	ErrorText       string              `json:"error_text,omitempty"`
	Session         SessionViewSnapshot `json:"session,omitempty"`
	Usage           kinds.Usage         `json:"usage,omitempty"`
}

type RunListQuery

type RunListQuery struct {
	Workspace string
	Status    string
	Mode      string
	Limit     int
}

type RunListResponse

type RunListResponse struct {
	Runs []Run `json:"runs"`
}

type RunResponse

type RunResponse struct {
	Run Run `json:"run"`
}

type RunShutdownState

type RunShutdownState struct {
	Phase       string    `json:"phase,omitempty"`
	Source      string    `json:"source,omitempty"`
	RequestedAt time.Time `json:"requested_at,omitempty"`
	DeadlineAt  time.Time `json:"deadline_at,omitempty"`
}

type RunSnapshot

type RunSnapshot struct {
	Run               Run                    `json:"run"`
	Jobs              []RunJobState          `json:"jobs,omitempty"`
	Transcript        []RunTranscriptMessage `json:"transcript,omitempty"`
	Usage             kinds.Usage            `json:"usage,omitempty"`
	Shutdown          *RunShutdownState      `json:"shutdown,omitempty"`
	Incomplete        bool                   `json:"incomplete,omitempty"`
	IncompleteReasons []string               `json:"incomplete_reasons,omitempty"`
	NextCursor        *StreamCursor          `json:"-"`
}

type RunSnapshotResponse

type RunSnapshotResponse struct {
	Run               Run                    `json:"run"`
	Jobs              []RunJobState          `json:"jobs,omitempty"`
	Transcript        []RunTranscriptMessage `json:"transcript,omitempty"`
	Usage             kinds.Usage            `json:"usage,omitempty"`
	Shutdown          *RunShutdownState      `json:"shutdown,omitempty"`
	Incomplete        bool                   `json:"incomplete,omitempty"`
	IncompleteReasons []string               `json:"incomplete_reasons,omitempty"`
	NextCursor        string                 `json:"next_cursor,omitempty"`
}

func RunSnapshotResponseFromSnapshot

func RunSnapshotResponseFromSnapshot(snapshot RunSnapshot) RunSnapshotResponse

func (RunSnapshotResponse) Decode

func (r RunSnapshotResponse) Decode() (RunSnapshot, error)

type RunTranscript

type RunTranscript struct {
	RunID             string              `json:"run_id"`
	Messages          []RunUIMessage      `json:"messages"`
	Session           SessionViewSnapshot `json:"session,omitempty"`
	Incomplete        bool                `json:"incomplete,omitempty"`
	IncompleteReasons []string            `json:"incomplete_reasons,omitempty"`
	NextCursor        *StreamCursor       `json:"-"`
}

type RunTranscriptMessage

type RunTranscriptMessage struct {
	Sequence    uint64          `json:"sequence"`
	Stream      string          `json:"stream"`
	Role        string          `json:"role"`
	Content     string          `json:"content"`
	MetadataRaw json.RawMessage `json:"metadata,omitempty"`
	Timestamp   time.Time       `json:"timestamp"`
}

type RunTranscriptResponse

type RunTranscriptResponse struct {
	RunID             string              `json:"run_id"`
	Messages          []RunUIMessage      `json:"messages"`
	Session           SessionViewSnapshot `json:"session,omitempty"`
	Incomplete        bool                `json:"incomplete,omitempty"`
	IncompleteReasons []string            `json:"incomplete_reasons,omitempty"`
	NextCursor        string              `json:"next_cursor,omitempty"`
}

func RunTranscriptResponseFromTranscript

func RunTranscriptResponseFromTranscript(transcript RunTranscript) RunTranscriptResponse

func (RunTranscriptResponse) Decode

type RunUIMessage

type RunUIMessage struct {
	ID          string             `json:"id"`
	Role        RunUIMessageRole   `json:"role"`
	MetadataRaw json.RawMessage    `json:"metadata,omitempty"`
	Parts       []RunUIMessagePart `json:"parts"`
}

type RunUIMessagePart

type RunUIMessagePart struct {
	Type        RunUIMessagePartType `json:"type"`
	ID          string               `json:"id,omitempty"`
	Text        string               `json:"text,omitempty"`
	State       string               `json:"state,omitempty"`
	ToolName    string               `json:"toolName,omitempty"`
	ToolCallID  string               `json:"toolCallId,omitempty"`
	Title       string               `json:"title,omitempty"`
	Input       json.RawMessage      `json:"input,omitempty"`
	RawInput    json.RawMessage      `json:"rawInput,omitempty"`
	Output      json.RawMessage      `json:"output,omitempty"`
	ErrorText   string               `json:"errorText,omitempty"`
	Data        json.RawMessage      `json:"data,omitempty"`
	Preliminary bool                 `json:"preliminary,omitempty"`
}

type RunUIMessagePartState

type RunUIMessagePartState string
const (
	RunUIMessagePartStateStreaming RunUIMessagePartState = "streaming"
	RunUIMessagePartStateDone      RunUIMessagePartState = "done"
)

type RunUIMessagePartType

type RunUIMessagePartType string
const (
	RunUIMessagePartText            RunUIMessagePartType = "text"
	RunUIMessagePartReasoning       RunUIMessagePartType = "reasoning"
	RunUIMessagePartDynamicTool     RunUIMessagePartType = "dynamic-tool"
	RunUIMessagePartProductizeEvent RunUIMessagePartType = "data-productize-event"
	RunUIMessagePartProductizeBlock RunUIMessagePartType = "data-productize-block"
)

type RunUIMessageRole

type RunUIMessageRole string
const (
	RunUIMessageRoleSystem    RunUIMessageRole = "system"
	RunUIMessageRoleUser      RunUIMessageRole = "user"
	RunUIMessageRoleAssistant RunUIMessageRole = "assistant"
)

type RunUIToolPartState

type RunUIToolPartState string
const (
	RunUIToolPartStateInputStreaming    RunUIToolPartState = "input-streaming"
	RunUIToolPartStateInputAvailable    RunUIToolPartState = "input-available"
	RunUIToolPartStateApprovalRequested RunUIToolPartState = "approval-requested"
	RunUIToolPartStateOutputAvailable   RunUIToolPartState = "output-available"
	RunUIToolPartStateOutputError       RunUIToolPartState = "output-error"
)

type SSEMessage

type SSEMessage struct {
	ID    string
	Event string
	Data  any
}

func HeartbeatMessage

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

func OverflowMessage

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

type SessionAvailableCommand

type SessionAvailableCommand struct {
	Name         string `json:"name"`
	Description  string `json:"description,omitempty"`
	ArgumentHint string `json:"argumentHint,omitempty"`
}

type SessionEntry

type SessionEntry struct {
	ID            string           `json:"id"`
	Kind          SessionEntryKind `json:"kind"`
	Title         string           `json:"title,omitempty"`
	Preview       string           `json:"preview,omitempty"`
	ToolCallID    string           `json:"tool_call_id,omitempty"`
	ToolCallState ToolCallState    `json:"tool_call_state,omitempty"`
	Blocks        []ContentBlock   `json:"blocks,omitempty"`
}

type SessionEntryKind

type SessionEntryKind string
const (
	SessionEntryKindAssistantMessage  SessionEntryKind = "assistant_message"
	SessionEntryKindAssistantThinking SessionEntryKind = "assistant_thinking"
	SessionEntryKindToolCall          SessionEntryKind = "tool_call"
	SessionEntryKindStderrEvent       SessionEntryKind = "stderr_event"
	SessionEntryKindRuntimeNotice     SessionEntryKind = "runtime_notice"
)

type SessionMetaState

type SessionMetaState struct {
	CurrentModeID     string                    `json:"current_mode_id,omitempty"`
	AvailableCommands []SessionAvailableCommand `json:"available_commands,omitempty"`
	Status            SessionStatus             `json:"status,omitempty"`
}

type SessionPlanEntry

type SessionPlanEntry struct {
	Content  string `json:"content"`
	Priority string `json:"priority"`
	Status   string `json:"status"`
}

type SessionPlanState

type SessionPlanState struct {
	Entries      []SessionPlanEntry `json:"entries,omitempty"`
	PendingCount int                `json:"pending_count,omitempty"`
	RunningCount int                `json:"running_count,omitempty"`
	DoneCount    int                `json:"done_count,omitempty"`
}

type SessionStatus

type SessionStatus string

type SessionViewSnapshot

type SessionViewSnapshot struct {
	Revision int              `json:"revision"`
	Entries  []SessionEntry   `json:"entries,omitempty"`
	Plan     SessionPlanState `json:"plan,omitempty"`
	Session  SessionMetaState `json:"session,omitempty"`
}

type StreamCursor

type StreamCursor struct {
	Timestamp time.Time
	Sequence  uint64
}

func CursorFromEvent

func CursorFromEvent(event events.Event) StreamCursor

func ParseCursor

func ParseCursor(raw string) (StreamCursor, error)

type SyncRequest

type SyncRequest struct {
	Workspace    string `json:"workspace,omitempty"`
	Path         string `json:"path,omitempty"`
	WorkflowSlug string `json:"workflow_slug,omitempty"`
}

type SyncResponse

type SyncResponse = SyncResult

type SyncResult

type SyncResult struct {
	WorkspaceID            string     `json:"workspace_id,omitempty"`
	WorkflowSlug           string     `json:"workflow_slug,omitempty"`
	SyncedAt               *time.Time `json:"synced_at,omitempty"`
	Target                 string     `json:"target,omitempty"`
	WorkflowsScanned       int        `json:"workflows_scanned,omitempty"`
	WorkflowsPruned        int        `json:"workflows_pruned,omitempty"`
	SnapshotsUpserted      int        `json:"snapshots_upserted,omitempty"`
	TaskItemsUpserted      int        `json:"task_items_upserted,omitempty"`
	ReviewRoundsUpserted   int        `json:"review_rounds_upserted,omitempty"`
	ReviewIssuesUpserted   int        `json:"review_issues_upserted,omitempty"`
	CheckpointsUpdated     int        `json:"checkpoints_updated,omitempty"`
	LegacyArtifactsRemoved int        `json:"legacy_artifacts_removed,omitempty"`
	SyncedPaths            []string   `json:"synced_paths,omitempty"`
	PrunedWorkflows        []string   `json:"pruned_workflows,omitempty"`
	Warnings               []string   `json:"warnings,omitempty"`
}

type TaskItem

type TaskItem struct {
	ID         string    `json:"id"`
	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"`
	SourcePath string    `json:"source_path"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type TaskItemsResponse

type TaskItemsResponse struct {
	Items []TaskItem `json:"items"`
}

type TaskRunRequest

type TaskRunRequest struct {
	Workspace        string          `json:"workspace"`
	PresentationMode string          `json:"presentation_mode,omitempty"`
	RuntimeOverrides json.RawMessage `json:"runtime_overrides,omitempty"`
}

type TaskWorkflowListResponse

type TaskWorkflowListResponse struct {
	Workflows []WorkflowSummary `json:"workflows"`
}

type TaskWorkflowResponse

type TaskWorkflowResponse struct {
	Workflow WorkflowSummary `json:"workflow"`
}

type TimeoutClass

type TimeoutClass string
const (
	TimeoutProbe      TimeoutClass = "probe"
	TimeoutRead       TimeoutClass = "read"
	TimeoutMutate     TimeoutClass = "mutate"
	TimeoutLongMutate TimeoutClass = "long_mutate"
	TimeoutStream     TimeoutClass = "stream"
)

func TimeoutClassForRoute

func TimeoutClassForRoute(method string, requestPath string) TimeoutClass

type TimeoutPolicy

type TimeoutPolicy struct {
	Class             TimeoutClass
	DefaultTimeout    time.Duration
	UsesClientTimeout bool
}

func TimeoutPolicyForClass

func TimeoutPolicyForClass(class TimeoutClass) TimeoutPolicy

type ToolCallState

type ToolCallState string

type TransportError

type TransportError struct {
	RequestID string         `json:"request_id"`
	Code      string         `json:"code"`
	Message   string         `json:"message"`
	Details   map[string]any `json:"details,omitempty"`
}

func TransportErrorEnvelope

func TransportErrorEnvelope(
	requestID string,
	status int,
	err error,
	details map[string]any,
	maskInternal bool,
) TransportError

type TransportErrorResponse

type TransportErrorResponse = TransportError

type ValidationResponse

type ValidationResponse = ValidationSuccess

type ValidationSuccess

type ValidationSuccess struct {
	Valid     bool      `json:"valid"`
	CheckedAt time.Time `json:"checked_at,omitempty"`
}

type WorkflowArchiveRequest

type WorkflowArchiveRequest struct {
	Workspace string `json:"workspace"`
	Force     bool   `json:"force,omitempty"`
}

type WorkflowRefRequest

type WorkflowRefRequest struct {
	Workspace string `json:"workspace"`
}

type WorkflowSummary

type WorkflowSummary struct {
	ID               string              `json:"id"`
	WorkspaceID      string              `json:"workspace_id"`
	Slug             string              `json:"slug"`
	ArchivedAt       *time.Time          `json:"archived_at,omitempty"`
	LastSyncedAt     *time.Time          `json:"last_synced_at,omitempty"`
	TaskCounts       *WorkflowTaskCounts `json:"task_counts,omitempty"`
	CanStartRun      *bool               `json:"can_start_run,omitempty"`
	StartBlockReason string              `json:"start_block_reason,omitempty"`
	ArchiveEligible  *bool               `json:"archive_eligible,omitempty"`
	ArchiveReason    string              `json:"archive_reason,omitempty"`
}

type WorkflowTaskCounts

type WorkflowTaskCounts struct {
	Total     int `json:"total"`
	Completed int `json:"completed"`
	Pending   int `json:"pending"`
}

type Workspace

type Workspace struct {
	ID              string     `json:"id"`
	RootDir         string     `json:"root_dir"`
	Name            string     `json:"name"`
	FilesystemState string     `json:"filesystem_state"`
	ReadOnly        bool       `json:"read_only"`
	HasCatalogData  bool       `json:"has_catalog_data"`
	WorkflowCount   int        `json:"workflow_count"`
	RunCount        int        `json:"run_count"`
	LastCheckedAt   *time.Time `json:"last_checked_at,omitempty"`
	LastSyncedAt    *time.Time `json:"last_sync_at,omitempty"`
	LastSyncError   string     `json:"last_sync_error,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
	UpdatedAt       time.Time  `json:"updated_at"`
}

type WorkspaceListResponse

type WorkspaceListResponse struct {
	Workspaces []Workspace `json:"workspaces"`
}

type WorkspaceRegisterRequest

type WorkspaceRegisterRequest struct {
	Path string `json:"path"`
	Name string `json:"name,omitempty"`
}

type WorkspaceRegisterResult

type WorkspaceRegisterResult struct {
	Workspace Workspace
	Created   bool
}

type WorkspaceResolveRequest

type WorkspaceResolveRequest struct {
	Path string `json:"path"`
}

type WorkspaceResponse

type WorkspaceResponse struct {
	Workspace Workspace `json:"workspace"`
}

type WorkspaceSyncResult

type WorkspaceSyncResult struct {
	Checked              int      `json:"checked"`
	Removed              int      `json:"removed"`
	Missing              int      `json:"missing"`
	Synced               int      `json:"synced"`
	WorkflowsPruned      int      `json:"workflows_pruned,omitempty"`
	SnapshotsUpserted    int      `json:"snapshots_upserted"`
	TaskItemsUpserted    int      `json:"task_items_upserted"`
	ReviewRoundsUpserted int      `json:"review_rounds_upserted"`
	ReviewIssuesUpserted int      `json:"review_issues_upserted"`
	Warnings             []string `json:"warnings,omitempty"`
}

type WorkspaceUpdateInput

type WorkspaceUpdateInput struct {
	Name string `json:"name,omitempty"`
}

type WorkspaceUpdateRequest

type WorkspaceUpdateRequest struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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