workbench

package
v0.144.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workbench projects persisted jobs and relay sessions into the conversation-first WEB-11 model. It owns projection and dispatch only; job and sessionrelay remain authoritative for execution and replies.

Index

Constants

View Source
const (
	MaxReviewComments     = 50
	MaxReviewCommentRunes = 4000
)
View Source
const MaxLayoutBodyBytes = 64 * 1024

Variables

View Source
var (
	ErrInvalidThreadID = errors.New("workbench: invalid thread id")
	ErrUnknownThread   = errors.New("workbench: unknown thread")
	ErrNotResumable    = errors.New("workbench: thread is not resumable")
	ErrEmptyTurn       = errors.New("workbench: turn text is required")
	ErrUnavailable     = errors.New("workbench: service unavailable")
	ErrInvalidLayout   = errors.New("workbench: invalid layout")
	ErrLayoutTooLarge  = errors.New("workbench: layout body exceeds 64 KiB")
	ErrMissingDiffBase = errors.New("workbench: first turn has no git diff base")
	ErrDiffUnavailable = errors.New("workbench: thread diff unavailable")
	ErrDiffTimeout     = errors.New("workbench: thread diff timed out")
	ErrInvalidReview   = errors.New("workbench: invalid review")
)

Functions

func JobThreadID

func JobThreadID(jobID, sessionID string) string

JobThreadID is the canonical job-event to workbench-thread mapping. A captured agent session groups every resume turn; a one-shot job stands alone.

func TerminalNeedsReview

func TerminalNeedsReview(status, agent string, hasChanges, seen bool) bool

TerminalNeedsReview is F16's single review predicate, shared by the workbench projection and Web Push dispatcher.

Types

type AttentionAction

type AttentionAction string
const (
	ActionAnswer AttentionAction = "answer"
	ActionReview AttentionAction = "review"
	ActionReply  AttentionAction = "reply"
)

type AttentionItem

type AttentionItem struct {
	ThreadID      string          `json:"thread_id"`
	ProjectKey    string          `json:"project_key"`
	Title         string          `json:"title"`
	Status        Status          `json:"status"`
	Action        AttentionAction `json:"action"`
	WaitingSince  int64           `json:"waiting_since"`
	JobID         string          `json:"job_id,omitempty"`
	InteractionID string          `json:"interaction_id,omitempty"`
	SessionID     string          `json:"session_id,omitempty"`
	DecisionID    string          `json:"decision_id,omitempty"`
}

type Counts

type Counts struct {
	Total         int `json:"total"`
	Blocked       int `json:"blocked"`
	Working       int `json:"working"`
	Review        int `json:"review"`
	Done          int `json:"done"`
	Idle          int `json:"idle"`
	OrphanBlocked int `json:"orphan_blocked"`
	OrphanReview  int `json:"orphan_review"`
}

type DiffSource

type DiffSource string
const (
	DiffSourceLive     DiffSource = "live"
	DiffSourceCaptured DiffSource = "captured"
)

type JobTurn

type JobTurn struct {
	JobID     string     `json:"job_id"`
	Status    string     `json:"status"`
	StartedAt int64      `json:"started_at"`
	EndedAt   int64      `json:"ended_at,omitempty"`
	Usage     *job.Usage `json:"usage,omitempty"`
}

type Jobs

type Jobs interface {
	ResumeJob(jobID, prompt, runner, callerID string) (job.JobResult, error)
	SaySession(jobID, message string) error
}

type Layout

type Layout struct {
	Version int64           `json:"version"`
	Body    json.RawMessage `json:"body"`
}

type LayoutVersionConflict

type LayoutVersionConflict struct {
	Current Layout
}

LayoutVersionConflict carries the server value a client must adopt after a stale optimistic write.

func (*LayoutVersionConflict) Error

func (e *LayoutVersionConflict) Error() string

type PatchInput

type PatchInput struct {
	Title  *string
	Seen   *bool
	Pinned *bool
}

type ProjectGroup

type ProjectGroup struct {
	ProjectKey string   `json:"project_key"`
	Status     Status   `json:"status"`
	Counts     Counts   `json:"counts"`
	Threads    []Thread `json:"threads"`
}

type Query

type Query struct {
	Project string
	Status  Status
	Q       string
	Since   int64
	// IncludeInternal also lists web session-messenger delivery jobs (all=1).
	IncludeInternal bool
}

type Relay

type Relay interface {
	Say(sessionID, answer, callerID string) (jobstore.PlanDecision, error)
}

type RelaySummary

type RelaySummary struct {
	SessionID   string `json:"session_id"`
	State       string `json:"state"`
	RelayMode   string `json:"relay_mode"`
	LastEvent   string `json:"last_event,omitempty"`
	LastMessage string `json:"last_message,omitempty"`
}

type Response

type Response struct {
	Projects  []ProjectGroup  `json:"projects"`
	Attention []AttentionItem `json:"attention"`
	Total     int             `json:"total"`
	Since     int64           `json:"since"`
}

type ReviewComment

type ReviewComment struct {
	Path string     `json:"path"`
	Line int        `json:"line"`
	Side ReviewSide `json:"side"`
	Text string     `json:"text"`
}

type ReviewInput

type ReviewInput struct {
	Summary  string          `json:"summary,omitempty"`
	Comments []ReviewComment `json:"comments,omitempty"`
}

type ReviewSide

type ReviewSide string
const (
	ReviewSideNew ReviewSide = "new"
	ReviewSideOld ReviewSide = "old"
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(store Store, jobs Jobs, relay Relay) *Service

func (*Service) Diff

func (s *Service) Diff(threadID string) (ThreadDiff, error)

Diff returns the changes made by a thread since its first recorded Git base. Git is consulted only for a server-local latest turn whose cwd still exists; remote and vanished working directories use the latest captured artifact.

func (*Service) GetLayout

func (s *Service) GetLayout(callerID string) (Layout, error)

func (*Service) List

func (s *Service) List(callerID string, query Query) (Response, error)

func (*Service) Patch

func (s *Service) Patch(callerID, threadID string, input PatchInput) (jobstore.WorkbenchThreadPref, error)

func (*Service) PutLayout

func (s *Service) PutLayout(callerID string, expectedVersion int64, body json.RawMessage) (Layout, error)

func (*Service) Review

func (s *Service) Review(callerID, threadID string, input ReviewInput) (TurnResult, error)

Review converts structured inline comments into one ordinary workbench turn. Turn remains the only dispatch owner, so its session, runner, and state gates apply unchanged to review continuations.

func (*Service) SeenAll

func (s *Service) SeenAll(callerID string) (int64, error)

func (*Service) Turn

func (s *Service) Turn(callerID, threadID, text string) (TurnResult, error)

type Status

type Status string
const (
	StatusBlocked       Status = "blocked"
	StatusWorking       Status = "working"
	StatusReview        Status = "review"
	StatusDone          Status = "done"
	StatusIdle          Status = "idle"
	StatusAwaitingInput Status = "awaiting_input"
)

type Store

type Store interface {
	LoadWorkbenchSnapshot(callerID string, since int64, includeInternal bool) (jobstore.WorkbenchSnapshot, error)
	ListWorkbenchThreadPrefs(callerID string) ([]jobstore.WorkbenchThreadPref, error)
	UpsertWorkbenchThreadPref(pref jobstore.WorkbenchThreadPref) error
	GetOrCreateWorkbenchSeenBaseline(callerID string, observedAt int64) (int64, error)
	SetWorkbenchSeenBaseline(callerID string, observedAt int64) (int64, error)
	GetWorkbenchLayout(callerID string) (jobstore.WorkbenchLayout, bool, error)
	PutWorkbenchLayout(callerID string, expectedVersion int64, bodyJSON string, updatedAt int64) (jobstore.WorkbenchLayout, bool, error)
	ListJobs(query jobstore.ListQuery) ([]jobstore.JobRecord, error)
	GetJob(id string) (jobstore.JobRecord, bool, error)
}

type Thread

type Thread struct {
	ID                  string            `json:"id"`
	Kind                ThreadKind        `json:"kind"`
	Status              Status            `json:"status"`
	RawStatus           string            `json:"raw_status,omitempty"`
	Stalled             bool              `json:"stalled,omitempty"`
	Title               string            `json:"title"`
	ProjectKey          string            `json:"project_key"`
	Agent               string            `json:"agent,omitempty"`
	Runner              string            `json:"runner,omitempty"`
	Cwd                 string            `json:"cwd,omitempty"`
	Interactive         bool              `json:"interactive,omitempty"`
	Resumable           bool              `json:"resumable"`
	Pinned              bool              `json:"pinned,omitempty"`
	SeenAt              int64             `json:"seen_at,omitempty"`
	StartedAt           int64             `json:"started_at"`
	UpdatedAt           int64             `json:"updated_at"`
	WaitingSince        int64             `json:"waiting_since,omitempty"`
	Turns               int               `json:"turns"`
	Usage               *Usage            `json:"usage,omitempty"`
	LatestJobID         string            `json:"latest_job_id,omitempty"`
	JobIDs              []string          `json:"job_ids,omitempty"`
	Jobs                []JobTurn         `json:"jobs,omitempty"`
	PendingInteractions []job.Interaction `json:"pending_interactions,omitempty"`
	Relay               *RelaySummary     `json:"relay,omitempty"`
}

type ThreadDiff

type ThreadDiff struct {
	Source    DiffSource       `json:"source"`
	Base      string           `json:"base"`
	Head      string           `json:"head,omitempty"`
	Files     []ThreadDiffFile `json:"files"`
	Patch     string           `json:"patch"`
	Truncated bool             `json:"truncated"`
	Commits   []job.Commit     `json:"commits,omitempty"`
	Notice    string           `json:"notice,omitempty"`
}

ThreadDiff is the conversation-level review snapshot. Captured responses are explicitly scoped to the latest turn; live responses span base..working-tree.

type ThreadDiffFile

type ThreadDiffFile struct {
	Path      string `json:"path"`
	Status    string `json:"status"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Binary    bool   `json:"binary"`
}

ThreadDiffFile is one path changed since the thread's first Git baseline. Untracked files use status "?" and deliberately carry no content or line counts.

type ThreadKind

type ThreadKind string
const (
	KindAgent ThreadKind = "agent"
	KindJob   ThreadKind = "job"
	KindRelay ThreadKind = "relay"
)

func ParseThreadID

func ParseThreadID(id string) (ThreadKind, string, error)

type TurnResult

type TurnResult struct {
	ThreadID   string `json:"thread_id"`
	JobID      string `json:"job_id,omitempty"`
	DecisionID string `json:"decision_id,omitempty"`
}

type Usage

type Usage struct {
	InputTokens      int64   `json:"input_tokens,omitempty"`
	OutputTokens     int64   `json:"output_tokens,omitempty"`
	CacheReadTokens  int64   `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int64   `json:"cache_write_tokens,omitempty"`
	TotalTokens      int64   `json:"total_tokens,omitempty"`
	CostUSD          float64 `json:"cost_usd,omitempty"`
}

Jump to

Keyboard shortcuts

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