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
- Variables
- func JobThreadID(jobID, sessionID string) string
- func TerminalNeedsReview(status, agent string, hasChanges, seen bool) bool
- type AttentionAction
- type AttentionItem
- type Counts
- type DiffSource
- type JobTurn
- type Jobs
- type Layout
- type LayoutVersionConflict
- type PatchInput
- type ProjectGroup
- type Query
- type Relay
- type RelaySummary
- type Response
- type ReviewComment
- type ReviewInput
- type ReviewSide
- type Service
- func (s *Service) Diff(threadID string) (ThreadDiff, error)
- func (s *Service) GetLayout(callerID string) (Layout, error)
- func (s *Service) List(callerID string, query Query) (Response, error)
- func (s *Service) Patch(callerID, threadID string, input PatchInput) (jobstore.WorkbenchThreadPref, error)
- func (s *Service) PutLayout(callerID string, expectedVersion int64, body json.RawMessage) (Layout, error)
- func (s *Service) Review(callerID, threadID string, input ReviewInput) (TurnResult, error)
- func (s *Service) SeenAll(callerID string) (int64, error)
- func (s *Service) Turn(callerID, threadID, text string) (TurnResult, error)
- type Status
- type Store
- type Thread
- type ThreadDiff
- type ThreadDiffFile
- type ThreadKind
- type TurnResult
- type Usage
Constants ¶
const ( MaxReviewComments = 50 MaxReviewCommentRunes = 4000 )
const MaxLayoutBodyBytes = 64 * 1024
Variables ¶
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") 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") ErrDiffTimeout = errors.New("workbench: thread diff timed out") ErrInvalidReview = errors.New("workbench: invalid review") )
Functions ¶
func JobThreadID ¶
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 ¶
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 DiffSource ¶
type DiffSource string
const ( DiffSourceLive DiffSource = "live" DiffSourceCaptured DiffSource = "captured" )
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 ProjectGroup ¶
type Relay ¶
type Relay interface {
Say(sessionID, answer, callerID string) (jobstore.PlanDecision, error)
}
type RelaySummary ¶
type Response ¶
type Response struct {
Projects []ProjectGroup `json:"projects"`
Attention []AttentionItem `json:"attention"`
Total int `json:"total"`
Since int64 `json:"since"`
}
func (Response) Summary ¶ added in v0.176.0
Summary returns a copy of the response whose threads carry only the fields a list view reads: the heavy per-thread parts (jobs, pending_interactions, cwd, interactive and the relay's last event / message) are left out. job_ids stays (a few bytes per thread; the web maps a freshly launched job back to its thread with it). Threads whose id is in full are kept complete. Counts, attention and everything else are unchanged. The receiver is not modified.
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 (*Service) Diff ¶
func (s *Service) Diff(threadID string) (ThreadDiff, error)
Diff returns the changes made by a thread since its recorded Git base — the first turn's, or the latest turn's own baseline when it is a continuation (see threadDiffBase). 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) Patch ¶
func (s *Service) Patch(callerID, threadID string, input PatchInput) (jobstore.WorkbenchThreadPref, 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.
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 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"`
}