ctl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 8 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 ctl holds the vocabulary the control tools share, below the feature packages that use it.

Index

Constants

View Source
const AgentHeader = "X-Atrium-Agent"

AgentHeader names the calling session. The room header is `RoomHeader`, shared with the board, so a control call scopes exactly the way a board request does.

LANDMINE THAT PICKED THESE NAMES: Claude Code blanks any header whose name contains TOKEN, SECRET, KEY, PASSWORD or AUTH. `X-Atrium-Agent` and `X-Atrium-Room` avoid all five.

View Source
const AuditErrMax = 200

AuditErrMax bounds the outcome a failed call writes.

View Source
const AuditWhatMax = 200

AuditWhatMax bounds the "what" of a line, which carries caller text such as an alias or a branch name.

View Source
const OriginTag = "origin:agent"

OriginTag marks a card that atrium_launch created. See OriginTag in internal/link.

Variables

View Source
var ItemWithheld = map[string]bool{
	"atrium_say": true, "atrium_peers": true, "atrium_task": true, "atrium_report": true,
}

ItemWithheld is what an item worker loses from the worker set: every way to talk to anything but the tool that ends its work. The same four the say endpoint refuses for, so a worker that reached one by lying about its class meets the refusal there.

View Source
var LaunchTools = map[string]bool{"atrium_launch": true, "atrium_launch_worker": true}

LaunchTools are what Elevated adds to a worker class.

View Source
var WorkerTools = map[string]bool{
	"atrium_status":       true,
	"atrium_peers":        true,
	"atrium_say":          true,
	"atrium_capabilities": true,
	"atrium_report":       true,

	"atrium_done":    true,
	"atrium_blocked": true,

	"atrium_link": true,

	"atrium_gate": true,

	"atrium_record": true,
	"atrium_task":   true,
	"atrium_alias":  true,

	"atrium_remind": true,

	"atrium_need": true,

	"atrium_publish": true,

	"atrium_prompt": true,

	"atrium_put":    true,
	"atrium_get":    true,
	"atrium_files":  true,
	"atrium_export": true,

	"atrium_git_push": true,

	"atrium_git_sync": true,

	"atrium_git_url": true,

	"atrium_ci": true,

	"atrium_resources": true,

	"atrium_close": true,

	"atrium_reports": true,

	"atrium_merge": true,
}

WorkerTools is the whole of the worker set, by name.

A TOOL IS IN THE WORKER SET ONLY WHEN IT IS NAMED HERE. `AddTool` filters on this list and not on a list of exclusions, so a tool added later, such as the git tools a `registerGit` adds, lands in `full` alone with no further change.

Functions

func AddTool

func AddTool[In, Out any](s *mcp.Server, class Class, t *mcp.Tool, h mcp.ToolHandlerFor[In, Out])

AddTool is `mcp.AddTool` for the class being built: it registers the tool when the class includes it and does nothing otherwise.

func AgentOf

func AgentOf(req *mcp.CallToolRequest) string

AgentOf and RoomOf read the per-request identity headers the go-sdk hands a tool on `Extra`. Absent when the caller is not one of atrium's sessions, which is an ordinary way to use these tools and not an error.

func AuditDetail

func AuditDetail(req *mcp.CallToolRequest, what string, err error) string

AuditDetail is `by <agent>@<caller room> (claimed): <what>, <outcome>`.

func AuditOutcome

func AuditOutcome(err error) string

AuditOutcome is `ok`, `refused: <why>` or the error's first line, cut to AuditErrMax characters.

func AuditWhat

func AuditWhat(what string) string

auditWhat strips control characters from what, so caller text cannot start a second line, and cuts it to AuditWhatMax characters. Besides C0, DEL and C1 it strips the line and paragraph separators and the bidi controls, which a log viewer uses to reorder the text around them.

func Audited

func Audited[In, Out any](c Caller, kind string, describe AuditDescribe[In, Out],
	h func(context.Context, *mcp.CallToolRequest, In) (*mcp.CallToolResult, Out, error),
) func(context.Context, *mcp.CallToolRequest, In) (*mcp.CallToolResult, Out, error)

Audited wraps a tool handler so one line is recorded after it returns, whether it succeeded, was refused or failed.

func CallerName

func CallerName(req *mcp.CallToolRequest) string

CallerName is who added a gate, as the ticker will tell it: `handle@room`.

func HasTag

func HasTag(tags []string, want string) bool

HasTag reports whether tags holds want, trimmed and case-insensitively.

func InClass

func InClass(name string, class Class) bool

InClass reports whether a tool is served to a class.

func RoomName

func RoomName(room string) string

RoomName names a room for a sentence.

func RoomOf

func RoomOf(req *mcp.CallToolRequest) string

Types

type AuditDescribe

type AuditDescribe[In, Out any] func(req *mcp.CallToolRequest, in In, out Out) (room, what string, record bool)

AuditDescribe turns one call into the two things a line needs: the target room and a short "what". record false writes nothing, for a call that turned out to be a read.

type BoardError

type BoardError struct {
	Code int
	Msg  string
	// NoSentence is an answer with no sentence in it, which is what a route the room
	// does not have looks like. A room older than an endpoint answers a bare 404.
	NoSentence bool
}

BoardError is a refusal from the board, with its status kept. The sentence is the whole of what a tool shows. The code is what the relay reads to tell a room that is not answering from a refusal that will never succeed.

func (*BoardError) Bare

func (e *BoardError) Bare() bool

Bare is whether the answer carried no sentence, which is a route that is not there rather than a thing that is not.

func (*BoardError) Error

func (e *BoardError) Error() string

func (*BoardError) HTTPStatus

func (e *BoardError) HTTPStatus() int

HTTPStatus is what the board answered, for a caller that reads a 404 as "no such thing".

type Caller

type Caller interface {
	Ask(ctx context.Context, method, path, room string, body, out any) error
	ResolvePeer(ctx context.Context, room, who string) (id, handle string, err error)
	ResolveCard(ctx context.Context, room, who string) (scope, id, handle string, err error)
	Relay(ctx context.Context, from string, req wire.RelayRequest) wire.RelayAnswer
	DeliverAs(ctx context.Context, room, to, fromWire, text, when, kind string, wake, force bool) wire.RelayAnswer
	LaunchOnRoom(ctx context.Context, in LaunchInput, harness, room, callerRoom,
		spawnedBy, spawnedByID, spawnedByDir string) (LaunchOutput, error)
	Audit(room, kind, detail string)
}

Caller is what a control tool asks of the hub's control server: a call to the board, a name resolved to a card, a message carried or a launch started on a room.

type Card

type Card struct {
	ID string `json:"id"`
	// LaunchReplay: the room answered with the card an earlier attempt filed under the same launch key.
	LaunchReplay bool     `json:"launch_replay"`
	Title        string   `json:"display_title"`
	Wire         string   `json:"wire_name"`
	Alias        string   `json:"alias"`
	Created      string   `json:"created_at"`
	Status       string   `json:"status"`
	Worktree     string   `json:"worktree"`
	Runner       string   `json:"runner"`
	Why          string   `json:"why"`
	Idle         int      `json:"idle_seconds"`
	Wait         int      `json:"wait_seconds"`
	Superv       bool     `json:"supervised"`
	Tags         []string `json:"tags"`
	// What the card was launched with. See docs/runtime/launch-options-design.md.
	Model         string   `json:"model"`
	Effort        string   `json:"effort"`
	LaunchArgs    []string `json:"launch_args"`
	LaunchEnvKeys []string `json:"launch_env_keys"`
	Activity      struct {
		What string `json:"what"`
	} `json:"activity"`
	Seen *Seen `json:"seen,omitempty"`
}

Card is the part of a task these tools report. The board's own shape is much larger and most of it is for drawing.

func CallerCard

func CallerCard(ctx context.Context, c Caller, room, agent string) (*Card, error)

CallerCard is the card the X-Atrium-Agent name belongs to on the caller's room.

func PickCard

func PickCard(tasks []Card, agent string) *Card

PickCard is the card a wire name belongs to. A wire name can be reused by a card that has since died, so a live one is preferred, then the newest, which is how resolvePeer orders an alias. Nil when no card answers to it.

type Class

type Class int

Class is which set of control tools a caller gets.

const (
	// ClassFull is every tool. The default, and what any doubt resolves to.
	ClassFull Class = iota
	// ClassWorker is the tools a worker uses to talk and to report.
	ClassWorker
	// ClassWorkerResident and ClassFullResident are those two with the done and blocked words of a card that stays open.
	ClassWorkerResident
	ClassFullResident
	// ClassWorkerItem is the worker set of an item: no say, no peers, no task and no report, and the done and blocked
	// words that name no launcher. See ItemTag.
	ClassWorkerItem
	// ClassWorkerReview is the worker set and atrium_review, for a card tagged ReviewTag.
	ClassWorkerReview
	// ClassChat is atrium_need and nothing else, for a card tagged ChatTag.
	ClassChat
)
const Elevated Class = 1 << 8

Elevated is a flag on a worker class: the same set plus LaunchTools, for a card tagged ElevatedTag.

func (Class) Base

func (c Class) Base() Class

Base is the class without Elevated.

type LaunchInput

type LaunchInput struct {
	Cwd    string `` /* 216-byte string literal not displayed */
	Repo   string `` /* 351-byte string literal not displayed */
	Branch string `` /* 143-byte string literal not displayed */
	Base   string `json:"base,omitempty" jsonschema:"where a new branch starts. default the clone's claude/main, else its default branch"`
	Home   bool   `` /* 152-byte string literal not displayed */
	Title  string `json:"title,omitempty" jsonschema:"what to call the card"`
	Why    string `json:"why,omitempty" jsonschema:"what this is for, read back later"`
	Prompt string `json:"prompt,omitempty" jsonschema:"the first instruction it gets"`
	// Brief is written to BRIEF.md in the new session's directory on the room and
	// read first, so it survives compaction and can be re-read.
	Brief  string   `` /* 189-byte string literal not displayed */
	Runner string   `json:"runner,omitempty" jsonschema:"which configured runner to start. default claude"`
	Tags   []string `` /* 184-byte string literal not displayed */
	// Resident marks a long-lived card. See ResidentTag.
	Resident bool `` /* 165-byte string literal not displayed */
	// Theme names the terminal palette the new session comes up in. Empty leaves
	// it to the board, which colours a themeless card from its repo, so an
	// agent-driven launch looks the same as a board-dialog one without this.
	Theme string `json:"theme,omitempty" jsonschema:"the terminal palette to come up in. empty lets the board colour it from the repo"`
	// Lean is on unless the caller turns it off. See leanLaunch.
	Lean *bool    `` /* 260-byte string literal not displayed */
	MCP  []string `` /* 145-byte string literal not displayed */
	// LeanAgents starts the worker lean and keeps its Agent tool plus these agents.
	LeanAgents []string `` /* 439-byte string literal not displayed */
	LeanSkills []string `` /* 287-byte string literal not displayed */
	// Superlean cuts a lean worker further. Absent leaves it to superleanLaunch.
	Superlean *bool `` /* 498-byte string literal not displayed */
	// Chat starts a thinking friend with no tools but atrium_need.
	Chat bool `` /* 339-byte string literal not displayed */
	// Model and Effort are mapped by the runner's harness row, Args and Env are
	// passed as given. See docs/runtime/launch-options-design.md.
	Model  string            `` /* 248-byte string literal not displayed */
	Effort string            `` /* 306-byte string literal not displayed */
	Args   []string          `` /* 206-byte string literal not displayed */
	Env    map[string]string `` /* 171-byte string literal not displayed */
	// Room launches on another room. The worker's reports come back across.
	Room  string   `` /* 141-byte string literal not displayed */
	Needs []string `` /* 253-byte string literal not displayed */
	// Kind is what sort of session this is. Empty is an ordinary worker.
	Kind string `` /* 760-byte string literal not displayed */
	// Scratch lets the launch start outside a git checkout.
	Scratch bool `` /* 232-byte string literal not displayed */
	// Item is the backlog item the worker is on, REQUIRED. See WorkTagPrefix and work_launch.go.
	Item string `` /* 481-byte string literal not displayed */
	// Isolated starts the worker with the isolated toolset. See ItemTag.
	Isolated  bool   `` /* 419-byte string literal not displayed */
	ItemOwner string `` /* 302-byte string literal not displayed */
	// Lifetime is not a parameter: atrium_launch_worker sets it to `work`, atrium_launch leaves it empty.
	Lifetime string `json:"-"`
	// Task is a task of an item: the room makes the folder and writes the brief. Never a parameter. See tasks_launch.go.
	Task *TaskBlock `json:"-"`
}

LaunchInput is the parameters of atrium_launch.

type LaunchOutput

type LaunchOutput struct {
	Card   string `json:"card"`
	Handle string `json:"handle"`
	Title  string `json:"title,omitempty"`
	Status string `json:"status"`
	Watch  string `json:"watch,omitempty"`
	// Brief is where the briefing was written on the room, when there was one.
	// Returned so the caller can add to it later: a peer that turns out to need
	// one more fact should be given it in the file it already reads.
	Brief string `json:"brief,omitempty"`
	// Model and Effort are what the card says it was started with, read back
	// from the room rather than echoed from the request.
	Model  string `json:"model,omitempty"`
	Effort string `json:"effort,omitempty"`
	Note   string `json:"note,omitempty"`
	// Recovered is a card found on the room after the launch's answer was lost, not one the answer named.
	Recovered bool `json:"-"`
}

LaunchOutput is what atrium_launch answers.

type RefusedError

type RefusedError struct{ Msg string }

RefusedError is a call turned away by a rule rather than one that failed, such as the launch cap. The audit line says `refused:` for it, which is the line somebody looks for, and a plain error is written as it came.

func (*RefusedError) Error

func (e *RefusedError) Error() string

type Seen

type Seen struct {
	TurnEndedAt string `json:"turn_ended_at,omitempty"`
	SeenAt      string `json:"seen_at,omitempty"`
	SeenVia     string `json:"seen_via,omitempty"`
	// Unseen is the latest turn having ended with nobody looking at it since.
	Unseen        bool     `json:"unseen"`
	OpenQuestions []string `json:"open_questions,omitempty"`
	// QuestionsUnparsed is a turn that had an Open Questions heading whose
	// items could not be read. They exist, and their text is not known.
	QuestionsUnparsed bool   `json:"questions_unparsed,omitempty"`
	QuestionsAt       string `json:"questions_at,omitempty"`
	AnsweredAt        string `json:"answered_at,omitempty"`
	AnsweredVia       string `json:"answered_via,omitempty"`
	// Answered is absent when no turn ever asked anything.
	Answered *bool `json:"answered,omitempty"`
}

Seen is whether the operator has seen a card's latest turn and answered its Open Questions. The room's `store.SeenView`, mirrored so internal/link learns nothing of the store. See docs/runtime/seen-design.md.

func (*Seen) OpenCount

func (s *Seen) OpenCount() int

OpenCount is how many questions are owed, counting an unreadable block as one so it is never reported as none.

type TaskBlock

type TaskBlock struct {
	BacklogID string   `json:"backlog_id"`
	TaskID    string   `json:"task_id"`
	Attempt   int      `json:"attempt"`
	Kind      string   `json:"kind"`
	Title     string   `json:"title"`
	Brief     string   `json:"brief"`
	Outputs   []string `json:"outputs"`
	ItemTitle string   `json:"item_title"`
	Context   string   `json:"context,omitempty"`
	Learnings []string `json:"learnings,omitempty"`
}

TaskBlock is a task of an item, as a launch carries it.

Jump to

Keyboard shortcuts

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