Documentation
¶
Index ¶
- Constants
- func Accept(value string, tok Token, c Candidate) (string, int)
- func Complete(value string, cursor int, src Sources) (Token, []Candidate)
- func ExpandMentions(text string, short map[string]string) string
- func GitFiles(ctx context.Context, repo string) ([]string, error)
- func GitShow(ctx context.Context, repo, sha string) (string, error)
- func MascotANSI() []string
- func MascotFrame(t time.Duration) []string
- func QR(text string) []string
- func Run(ctx context.Context, o Options) error
- func RunSetup(ctx context.Context, o SetupOptions) error
- func RunShort(root string) string
- type Agent
- type Backend
- type Block
- type Candidate
- type Comm
- type Commit
- type Connector
- type Demo
- func (d *Demo) Answer(_ context.Context, _ string, text, decision string) error
- func (d *Demo) Btw(ctx context.Context, root, text string) error
- func (d *Demo) Cancel(context.Context, string) error
- func (d *Demo) Commits(context.Context, string, time.Time) ([]Commit, error)
- func (d *Demo) ConnectTelegram(ctx context.Context, token string) (*client.Telegram, error)
- func (d *Demo) Continue(string)
- func (d *Demo) Diff(_ context.Context, sha, _ string) (string, error)
- func (d *Demo) DisconnectTelegram(context.Context) error
- func (d *Demo) History(context.Context) ([]lg.Entry, error)
- func (d *Demo) Message(_ context.Context, to, subtask, text string, direct bool) error
- func (d *Demo) Online(_ context.Context, handles []string) ([]string, error)
- func (d *Demo) Output(_ context.Context, path string) (string, error)
- func (d *Demo) PairTelegram(context.Context) (*client.Telegram, error)
- func (d *Demo) Runs(context.Context) ([]RunInfo, error)
- func (d *Demo) Send(context.Context, string, []string) (string, error)
- func (d *Demo) SetTelegramLevel(_ context.Context, level string) (*client.Telegram, error)
- func (d *Demo) Shells(context.Context) ([]Shell, error)
- func (d *Demo) Stop(_ context.Context, pid int) error
- func (d *Demo) StopSubtask(_ context.Context, subtask string) error
- func (d *Demo) Stream(ctx context.Context, fn func(lg.Entry), connected func(bool, error)) error
- func (d *Demo) Telegram(context.Context) (*client.Telegram, error)
- func (d *Demo) TestTelegram(context.Context) error
- func (d *Demo) Updates() <-chan Update
- func (d *Demo) Waiting(context.Context) ([]Wait, error)
- type Dot
- type Live
- func (l *Live) Answer(ctx context.Context, taskID, text, decision string) error
- func (l *Live) Btw(ctx context.Context, root, text string) error
- func (l *Live) Cancel(ctx context.Context, taskID string) error
- func (l *Live) Commits(ctx context.Context, short string, since time.Time) ([]Commit, error)
- func (l *Live) ConnectTelegram(ctx context.Context, token string) (*client.Telegram, error)
- func (l *Live) Continue(root string)
- func (l *Live) Diff(ctx context.Context, sha, task string) (string, error)
- func (l *Live) DisconnectTelegram(ctx context.Context) error
- func (l *Live) Files(ctx context.Context) ([]string, error)
- func (l *Live) History(ctx context.Context) ([]lg.Entry, error)
- func (l *Live) Message(ctx context.Context, to, subtask, text string, direct bool) error
- func (l *Live) Online(ctx context.Context, handles []string) ([]string, error)
- func (l *Live) PairTelegram(ctx context.Context) (*client.Telegram, error)
- func (l *Live) Runs(ctx context.Context) ([]RunInfo, error)
- func (l *Live) Send(ctx context.Context, text string, images []string) (string, error)
- func (l *Live) SetTelegramLevel(ctx context.Context, level string) (*client.Telegram, error)
- func (l *Live) StopSubtask(ctx context.Context, subtask string) error
- func (l *Live) Stream(ctx context.Context, fn func(lg.Entry), connected func(bool, error)) error
- func (l *Live) Telegram(ctx context.Context) (*client.Telegram, error)
- func (l *Live) TestTelegram(ctx context.Context) error
- func (l *Live) Waiting(ctx context.Context) ([]Wait, error)
- type Member
- type Options
- type Packet
- type PlanEntry
- type Preview
- type Procs
- type Raw
- type RunInfo
- type Screen
- type SetupOptions
- type Shell
- type Size
- type Sources
- type State
- func (s *State) Apply(e lg.Entry, now time.Time)
- func (s *State) Count(id int, u *UI) int
- func (s *State) CycleFocus(now time.Time, dir ...int)
- func (s *State) Feed(u Update)
- func (s *State) NowLine(handle string) string
- func (s *State) Prune(now time.Time)
- func (s *State) Rate(now time.Time, n int) (float64, []int)
- func (s *State) Render(sc Screen) string
- func (s *State) SetCommits(cs []Commit)
- func (s *State) SetMembers(ms []Member)
- func (s *State) SetOnline(handles []string)
- func (s *State) Short(handle string) string
- func (s *State) SubProgress(st *plan.Subtask, now time.Time) float64
- func (s *State) TeamCost() float64
- type Task
- type Team
- type Token
- type UI
- type Update
- type Usage
- type Wait
Constants ¶
const BtwTag = "btw"
BtwTag marks a btw task in the activity log's tags.
const PacketTime = 1400 * time.Millisecond
PacketTime is how long a packet takes from sender to recipient.
Variables ¶
This section is empty.
Functions ¶
func Accept ¶
Accept replaces tok with c and a trailing space; it returns the new value and the cursor (a rune offset) after the space.
func ExpandMentions ¶
ExpandMentions turns short @mentions into full handles (@sonnet-1 into @halo-sonnet-1). short maps the name without '@' to the handle.
func MascotANSI ¶
func MascotANSI() []string
MascotANSI is a still mascot in 24-bit color, for text printed outside the TUI (usage, goodbyes).
func MascotFrame ¶
MascotFrame is the mascot at t into its loop, uncolored: five rows of five cells (halo, gap, body). Callers that print plain text use it.
func QR ¶
QR draws text as a QR code, two modules a line, dark on light whatever the terminal's colors, with a quiet zone so phones read it.
Types ¶
type Agent ¶
type Agent struct {
Member
Online bool
State string // idle, working, asking, waiting, failed, done
Sub string // the subtask it works on
Log []string
Since time.Time
LastAct time.Time
Usage Usage // tokens and cost, for agents this Halo hosts
Feed []*Block // the live transcript, for agents this Halo hosts
// contains filtered or unexported fields
}
Agent is what the TUI knows about one address.
type Backend ¶
type Backend interface {
// Stream calls fn for each activity entry until ctx ends.
Stream(ctx context.Context, fn func(lg.Entry), connected func(bool, error)) error
// Send starts a run: a prompt to the lead, with images (files on this machine)
// attached. It returns the root task ID.
Send(ctx context.Context, text string, images []string) (string, error)
// Waiting lists the tasks waiting on you, oldest first.
Waiting(ctx context.Context) ([]Wait, error)
// Answer answers a waiting task; decision is "approve", "reject" or "".
Answer(ctx context.Context, taskID, text, decision string) error
// Cancel cancels a task.
Cancel(ctx context.Context, taskID string) error
// Online lists the roster's agents with a tunnel up.
Online(ctx context.Context, handles []string) ([]string, error)
// Commits lists the commits of run short since it started.
Commits(ctx context.Context, short string, since time.Time) ([]Commit, error)
// Diff returns a commit's git show output. task, if set, is the task that
// published the commit to Lagrange, which has its patch when git doesn't.
Diff(ctx context.Context, sha, task string) (string, error)
// Runs lists your runs with the lead, newest first.
Runs(ctx context.Context) ([]RunInfo, error)
// History returns the activity log so far, oldest first.
History(ctx context.Context) ([]lg.Entry, error)
// Continue makes later prompts continue run root's conversation, so the lead
// remembers it; "" starts a fresh one.
Continue(root string)
// Message sends the person's message to an agent during a run: to is the lead's
// or a worker's handle, subtask the subtask it is about ("" for the worker's
// current one). direct sends it straight to the worker, in its session;
// otherwise the lead relays it. It fails when there is no such run or subtask.
Message(ctx context.Context, to, subtask, text string, direct bool) error
// Btw asks the lead something on the side of run root, like Claude Code's
// /btw: it starts no run and changes no plan. The lead answers when it can;
// the answer arrives as the btw task completing.
Btw(ctx context.Context, root, text string) error
// StopSubtask stops the worker of a running subtask: its task is canceled and the
// lead hears it was on purpose. It fails when the subtask isn't running.
StopSubtask(ctx context.Context, subtask string) error
}
Backend is where the TUI gets its events and sends what you do.
type Block ¶
type Block struct {
Kind string // "user", "think", "say", "tool", "plan"
Task string
Text string
ID string // the tool call
Title string
Tool string // the ACP tool kind: execute, read, edit, search, fetch, …
Status string // pending, in_progress, completed, failed
Input json.RawMessage
Output string
Started time.Time
Ended time.Time
Entries []PlanEntry
}
Block is one entry of an agent's live transcript.
type Comm ¶
type Comm struct {
At time.Time
Kind string // task, ask, reply, review, fail, hub
From, To, Text string // Text is the whole message
Sub string // the subtask it is about
}
Comm is one line of the agent-to-agent log.
type Commit ¶
type Commit struct {
SHA, Author, Subject, Refs string
At time.Time
Files, Add, Del int
Sub string // the subtask, from the subject ("halo: S2 …")
Parents []string // parent SHAs, first parent first
Task string // the task that published it to Lagrange, if one did
}
Commit is a commit of the current run: a worker's subtask, a merge into the run branch, or the run landing on your branch.
func GitCommits ¶
GitCommits lists a run's commits in repo: everything on its branches (halo/<short> and halo/<short>-*), plus what Halo committed on the checked-out branch since the run started (the merge that lands it).
type Connector ¶
type Connector interface {
Telegram(ctx context.Context) (*client.Telegram, error)
ConnectTelegram(ctx context.Context, token string) (*client.Telegram, error)
PairTelegram(ctx context.Context) (*client.Telegram, error)
SetTelegramLevel(ctx context.Context, level string) (*client.Telegram, error)
TestTelegram(ctx context.Context) error
DisconnectTelegram(ctx context.Context) error
}
Connector is a Backend that can connect Telegram.
type Demo ¶
type Demo struct {
Human, Prefix string
// contains filtered or unexported fields
}
Demo is a Backend that plays a scripted run, shaped exactly like Lagrange's activity log, so the TUI can be tried (and screenshotted) without a server or tokens. Answering the plan approval moves it on; it approves itself after 8 s.
func (*Demo) Btw ¶
Btw implements Backend: a fake btw task that the lead answers a few seconds later.
func (*Demo) ConnectTelegram ¶
ConnectTelegram implements Connector.
func (*Demo) DisconnectTelegram ¶
DisconnectTelegram implements Connector.
func (*Demo) Message ¶
Message implements Backend: the demo has no agents to reach, so it shows the message as a fake human_message task to the lead that completes at once.
func (*Demo) PairTelegram ¶
PairTelegram implements Connector.
func (*Demo) SetTelegramLevel ¶
SetTelegramLevel implements Connector.
func (*Demo) StopSubtask ¶
StopSubtask implements Backend: the scripted run goes on, but the request shows.
func (*Demo) TestTelegram ¶
TestTelegram implements Connector.
type Live ¶
type Live struct {
Server, Key, Human, Lead string
Repo string // the git repository the team works on
Since int64 // where the stream starts: 0 replays everything, -1 starts now
// Token returns an address token (the lead's) for Message: A2A calls with
// Halo's metadata need one, since the API key only works on /api. It is a func
// because the hosted team may provision its tokens after the TUI starts. nil or
// "" uses Key.
Token func() string
// contains filtered or unexported fields
}
Live is the Backend of a Lagrange server.
func (*Live) Btw ¶
Btw implements Backend. The task nests under the run (Lagrange-Task) and is tagged btw, so every client shows it in the run instead of as a new one.
func (*Live) ConnectTelegram ¶
ConnectTelegram implements Connector.
func (*Live) DisconnectTelegram ¶
DisconnectTelegram implements Connector.
func (*Live) Message ¶
Message implements Backend: it sends the lead a message with Halo's human_message metadata, which the hosting Halo routes without a Claude turn of the lead, and returns the lead's refusal as an error.
func (*Live) PairTelegram ¶
PairTelegram implements Connector.
func (*Live) SetTelegramLevel ¶
SetTelegramLevel implements Connector.
func (*Live) StopSubtask ¶
StopSubtask implements Backend, with Halo's stop_subtask metadata, which the hosting Halo handles like a human_message.
func (*Live) TestTelegram ¶
TestTelegram implements Connector.
type Member ¶
type Member struct {
Handle, Name, Model, Role string
}
Member is a roster entry as the TUI sees it.
type Options ¶
type Options struct {
Backend Backend
State *State
Server string
Handles []string // the roster's agent handles, for the online count
// Team is the roster this Halo hosts; nil when it only watches, for the reason
// in Watching.
Team Team
Watching string
// Notes are messages from the agents' host (errors, restarts) for the header.
Notes <-chan string
// Feed is the raw output of the hosted agents; Procs their shells. Both are
// nil when this Halo only watches.
Feed <-chan Update
Procs Procs
// Preview finds the live preview of the run with this short id: the run
// worktree and the command that serves it, or ok=false for a non-web project.
Preview func(short string) (dir, cmd string, ok bool)
// ImageDir is where images pasted into a prompt are kept for the agents to
// read; "" uses a folder in the system's temp directory.
ImageDir string
// Quiet turns off the ping (a desktop notification and a bell) when
// something new waits on you.
Quiet bool
}
Options configure the TUI.
type Preview ¶
type Preview struct {
Dir string // the run branch's worktree
Cmd string // the command that serves it
}
Preview is the live preview of a web run: where the run branch's code is and the command that serves it. The zero value means the project isn't a web one.
type Procs ¶
type Procs interface {
Shells(ctx context.Context) ([]Shell, error)
// Output is the end of a shell's output file.
Output(ctx context.Context, path string) (string, error)
// Stop ends a shell and everything it started.
Stop(ctx context.Context, pid int) error
}
Procs reads the hosted agents' processes. Only the Halo that hosts the team has them.
type RunInfo ¶
type RunInfo struct {
ID, ContextID string
Title, State string
Cost float64 // what the run's agents reported spending
Tasks int
Started, Updated time.Time
}
RunInfo is a past run, for /resume.
type Screen ¶
type Screen struct {
W, H int
Frame int
Now time.Time
Server string
Connected bool
Online int
Waiting int
Popup []string // the completion list, drawn above the input
Bottom string // replaces the bottom of the screen when set (answering)
BottomTag string
Flash string
UI *UI
Team string // "team here" or "watch-only"
Procs bool // this Halo can see the agents' shells
Overlay []string // a box drawn in the middle (the /resume list)
Runs []RunInfo // your runs with the lead, for the full-screen comms
RunSel int // the run selected in that list
}
Screen is everything the view needs besides the state.
type SetupOptions ¶
type SetupOptions struct {
State *config.State
Roster *config.Config
RosterPath string
// First is a first run: the screen opens on the server, which must work.
First bool
// Check checks a server and API key and returns the person's handle.
Check func(ctx context.Context, server, key string) (string, error)
// Login is the server and key `lagrange login` saved, if any.
Login func() (server, key string)
// Provision creates the team's addresses on the server.
Provision func(ctx context.Context, cfg *config.Config, st *config.State) error
// Connector talks to a server's Telegram settings.
Connector func(server, key string) Connector
// LookPath finds a command on PATH (default exec.LookPath).
LookPath func(string) (string, error)
}
SetupOptions is what setup works on.
type Size ¶
type Size int
Size is how much of the screen a panel takes. Growing takes space from the neighbours step by step: first the panel's column, then the orbit's width, then the whole screen. Shrinking below normal collapses a panel to a one-line bar.
type Sources ¶
type Sources struct {
Agents []Candidate // Text is the short name (@sonnet-1), Desc the role
Subtasks []Candidate // Text is #S3, Desc the title
Files []string
}
Sources is what completion draws on.
type State ¶
type State struct {
Human, Lead, Reviewer string
Prefix string
Order []string
Agents map[string]*Agent
Root string
RootAt time.Time
RootEnd time.Time
RootState string
Prompt string
Tasks map[string]*Task
Plan *plan.Plan
// Report is the run's latest situation report (lagrange/report); ReportNew is
// set when a final one arrives live, so the TUI opens the summary card.
Report *report.Report
ReportNew bool
Follow bool
// Hosted is set when this Halo hosts the team: the agents' raw output comes
// through Feed, so the activity log's copy of it is skipped.
Hosted bool
Comms []Comm
Commits []Commit
Raw []Raw
Packets []Packet
Dots []Dot
HubAt time.Time
Events int
Questions int
Reviews int
Seq int64
// Pin, when set, is the only root task that starts a run (a resumed run).
Pin string
// Hint is shown while there is no run, e.g. how to resume the last one.
Hint string
// Shells are the processes the hosted agents run.
Shells []Shell
// Preview is the live preview of the run, when it is a web project.
Preview Preview
Focus string
// contains filtered or unexported fields
}
State folds the activity log into what the panes show.
func NewState ¶
NewState returns an empty state for a roster. members must include the lead, the reviewer and the human.
func (*State) CycleFocus ¶
CycleFocus moves the focus to the next agent and holds it there for a while.
func (*State) Feed ¶
Feed folds a raw update into the agent's transcript: chunks join the block before them, tool call updates change the call they belong to.
func (*State) NowLine ¶
NowLine is what an agent is doing right now, in one line: its newest tool call, thought or message from the live transcript, or else the newest tool call Lagrange saw.
func (*State) Rate ¶
Rate returns events per second over the last 3 s, and per-second counts for the last n seconds.
func (*State) SetCommits ¶
SetCommits merges commits into the run's list, oldest first. Commits seen once stay, so the list survives the run's branches being deleted after it lands.
func (*State) SetMembers ¶
SetMembers replaces the roster, keeping what the TUI knows about agents that stay.
func (*State) SubProgress ¶
SubProgress estimates how far a running subtask is, from its worker's tool calls.
type Task ¶
type Task struct {
ID, Parent, Sender, Recipient, State, Summary, Sub, Kind string
Tools int
Started, Ended time.Time
// contains filtered or unexported fields
}
Task is a task of the current run.
type Team ¶
type Team interface {
// Members is the roster, without you.
Members() []Member
// SetMembers saves the roster and restarts the agents with it.
SetMembers(ctx context.Context, ms []Member) error
// Land merges run short into the checked-out branch and removes its
// branches and worktrees.
Land(ctx context.Context, short string) (string, error)
}
Team is the roster this Halo hosts. It is nil when Halo only watches: another Halo hosts the team, or this directory isn't a git repository.
type Token ¶
Token is the word being typed: runes [Start,End) of the input, led by '@' (an agent), '#' (a subtask) or 'p' (a path).
type UI ¶
type UI struct {
Focus int
Size [nPanes + 1]Size
Cur [nPanes + 1]*pcursor
Help bool
Query string
Filter string // comms: only messages from or to this handle
Diffs map[string]string // commit SHA → git show output
Calls bool // agent: the tool calls Lagrange saw, not the live transcript
Out map[int]string // shell pid → the end of its output
// BoardOff is the stacked plan board's scroll offset.
BoardOff int
}
UI is the view state that isn't part of the run: focus, sizes, selections and overlays.
func (*UI) Move ¶
Move moves the focused panel's selection (or the open item's scroll) by d, for a list of n items.
type Update ¶
type Update struct {
Agent, Task, Type string
Context string // the A2A context: one ACP session per context
Raw json.RawMessage
At time.Time
}
Update is one raw ACP session update from an agent this Halo hosts: what Claude Code streams while it works, before Lagrange sees any of it.
type Usage ¶
type Usage struct {
Used, Size int64 // tokens in the newest session's context, of its window
Sessions map[string]float64 // A2A context → that session's cost so far, USD
Currency string
}
Usage is what an agent's Claude Code sessions report through ACP usage updates: the newest context window fill, and the cost of every session.