console

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package console is the connector's console: one full-screen view, in the terminal, of what a profile's connector listens to, what it is working on, what it did, and whether it is well, with a line to talk to its orchestrator.

What it is beside the connector

The console is a process of its own. It reads what `basecamp connect status` reads, the same way, and so it runs beside a connector, before one has started, and after one has stopped: a connector that starts while the console is open shows as it comes up. Closing the console leaves the connector as it was.

Who can open it

Whoever can run the command as the person the connector runs as. It listens on nothing: what it shows is read from files only that person can read, and what it tells the orchestrator goes over the runner's socket, in a directory only that person can enter.

What it shows is not trusted

A recording's title is whatever someone in Basecamp wrote, and a worker's report is whatever a coding agent wrote. Every such string is stripped of terminal control sequences before it is drawn (plain, text), so neither can move the cursor, restyle the screen or write to the terminal's title.

Index

Constants

View Source
const (
	StatusPass = "pass"
	StatusWarn = "warn"
	StatusFail = "fail"
	StatusSkip = "skip"
)

Check statuses, as `basecamp connect doctor` reports them.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Options) error

Run shows the console until the person closes it or ctx ends. It is the one place this package starts a bubbletea program, so it is where the non-interactive floor holds: without a terminal on both standard input and standard output it returns tui.ErrNotInteractive and draws nothing.

Types

type Check

type Check struct {
	Name    string
	Status  string
	Message string
	Hint    string
}

Check is one of doctor's checks.

type Connector

type Connector struct {
	// Running says a connector holds this profile's lock.
	Running bool
	PID     int
	// StartedAt is when the running connector started, as it wrote.
	StartedAt string
	// Hold is the standing hold, under which nothing is handed off.
	Hold *connector.HoldStatus
	// LastChange is the last run's own record of itself.
	LastChange *connector.ConnectionStatus
}

Connector is the connector's process and its own record of itself.

type Health

type Health struct {
	At     time.Time
	Checks []Check
	Agents []runner.Installed
}

Health is what reading it costs a request to Basecamp or a process started: doctor's checks and the coding agents installed. It is read when the console opens and when the person asks again, not with every snapshot.

type Options

type Options struct {
	// Snapshot reads the connector's state as it stands. It is called
	// about once a second, one call at a time.
	Snapshot func(ctx context.Context) *Snapshot
	// Health runs doctor's checks and asks each coding agent its version.
	// It is called when the console opens and when the person asks again.
	Health func(ctx context.Context) *Health
	// Say gives the orchestrator a message from the person and waits for
	// its answer.
	Say func(ctx context.Context, message string) (string, error)
	// Open opens an address in the person's browser.
	Open func(url string) error
	// Theme is the palette it is drawn in.
	Theme tui.Theme
}

Options are what a console reads and where it sends.

type Person

type Person struct {
	ID   int64
	Name string
}

Person is someone connect.json names: by id, and by name once Basecamp has been asked.

type PingGuests

type PingGuests struct {
	PingID int64
	People []Person
}

PingGuests are the people let into one Ping.

type Pings

type Pings struct {
	// Hears is nil when it cannot be told.
	Hears   *bool
	Because string
	// Twice says another connector on this computer answers them too.
	Twice bool
	// Guests are the people let into one Ping each, as participants.
	Guests []PingGuests
	Error  string
}

Pings is whether this profile's connector answers the agent's Pings.

type Project

type Project struct {
	ID               int64
	Name             string
	URL              string
	WatchCompletions bool
	// Campfires counts the chats it answers without being mentioned.
	Campfires int
}

Project is a project the connector serves.

type Request

type Request struct {
	EventID     int64
	Trigger     string
	EventType   string
	ProjectID   int64
	ProjectName string
	URL         string
	State       string
	Reason      string
	At          time.Time
}

Request is one request the connector let in and what became of it.

type Rule

type Rule struct {
	When   []string
	Worker runner.Spec
}

Rule is one runner.json rule: the conditions a request must meet, in words, and the worker it then gets.

type Runner

type Runner struct {
	// Live says a connector is running with an orchestrator now.
	Live         bool
	Orchestrator runner.Spec
	Worker       runner.Spec
	Permissions  string
	// MaxWorkers is the cap on workers running at once, zero for none: the
	// one a running connector started with, and otherwise runner.json's.
	// KeptMaxWorkers is runner.json's, which a running connector takes up
	// at its next start.
	MaxWorkers     int
	KeptMaxWorkers int
	// Rules are runner.json's, in the order they are tried.
	Rules []Rule
	// Turns, Waiting and SetAside are the orchestrator's: the turns it has
	// finished, the messages it has not handled, and those it gave up on.
	Turns    int
	Waiting  int
	SetAside int
	// Process is the process group the orchestrator's session still names.
	Process int
	// ConfigError is why runner.json cannot be read as written. No agent
	// is started until it can.
	ConfigError string
}

Runner is the connector doing the work itself: its settings as runner.json has them and its orchestrator.

type Snapshot

type Snapshot struct {
	At        time.Time
	Profile   string
	AccountID string
	Agent     Person
	Connector Connector
	Projects  []Project
	Pings     Pings
	Trust     Trust
	// Runner is nil when the connector hands requests to the session that
	// started it and no runner has been set up or has run.
	Runner *Runner
	// Now and Done are the runner's workers: those running or waiting, and
	// those that ended, each newest first.
	Now  []runner.WorkerActivity
	Done []runner.WorkerActivity
	// Requests are the latest requests the connector let in, from its
	// ledger, and Held those waiting for a person.
	Requests []Request
	Held     []connector.HeldStatus
	// Notes are the parts that could not be read, and why.
	Notes []string
}

Snapshot is everything the console shows that is read from this computer: ids, states, names and timestamps, as `basecamp connect status` shows, and for the runner's workers the title of what each was asked on and what the worker reported. It holds no feed position and no credential, and not the body of any request.

type Trust

type Trust struct {
	Mode             string
	Operator         Person
	Allowlist        []Person
	AllowAssignments bool
	Agents           []Person
}

Trust is who may give the agent work.

Jump to

Keyboard shortcuts

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