Documentation
¶
Overview ¶
Package daemon wires the three layers together: the store owns state, the hub serves agents, and the api serves humans.
The two listeners are separate so one can be closed without the other. When the store halts the agent-facing listener closes and does not reopen, so every runner sees connection-refused and parks on the backoff it already has, while the human-facing listener stays up to say what broke.
Index ¶
- Constants
- Variables
- func BriefPrompt(file, prompt string) string
- func CheckBlockedReason(reason string) string
- func CountCards(path string) int
- func DefaultDBPath() string
- func DiskLevel(free, warn, critical uint64) string
- func EndsTheSession(reason string) bool
- func EnrollZitiInto(token, name, dir string) (string, string, error)
- func IsAskingTool(tool string) bool
- func ItemBriefPrompt(file, prompt string) string
- func PromptToolNames() []string
- func ResidentBriefPrompt(file, prompt string) string
- func ResolveItemOwner(spec, creator string) (kind, owner string, err error)
- func StateDir() string
- func ToolLocations() map[string]string
- type ActionResult
- type Activity
- type ActivityEvent
- type ActivityTracker
- type ArchiveWorkersResult
- type ArchivedWorker
- type AutoDecision
- type Autocompact
- type BackfillResult
- type BudgetView
- type ContextSize
- type CullResult
- type Daemon
- func (d *Daemon) ArchiveWorkers(dryRun bool) (*ArchiveWorkersResult, error)
- func (d *Daemon) BoardHandler() http.Handler
- func (d *Daemon) CancelDispatch(id string) error
- func (d *Daemon) CancelPending(taskID, reason string) (int, error)
- func (d *Daemon) Close() error
- func (d *Daemon) CloseShell(taskID string)
- func (d *Daemon) Cull(taskID, into string) (*CullResult, error)
- func (d *Daemon) CullProved(taskID, into, tip string) (*CullResult, error)
- func (d *Daemon) DiskCheck() DiskStatus
- func (d *Daemon) DiskFree() any
- func (d *Daemon) DiskNotice() string
- func (d *Daemon) DiskReclaim(ctx context.Context, now time.Time) DiskStatus
- func (d *Daemon) DiskState() any
- func (d *Daemon) DiskView() (any, error)
- func (d *Daemon) Dispatches() any
- func (d *Daemon) EnsureShell(taskID string) error
- func (d *Daemon) HoldCull(taskID, by string) error
- func (d *Daemon) HostNotice() string
- func (d *Daemon) HostState() any
- func (d *Daemon) HubDeleteBranch(ctx context.Context, card, dir, hubRepo, branch string) error
- func (d *Daemon) HubRefreshBranch(ctx context.Context, card, dir, hubRepo, branch string) error
- func (d *Daemon) Kill(taskID string) error
- func (d *Daemon) Launch(req shared.LaunchRequest) (*store.Task, error)
- func (d *Daemon) LoginNeededReason() string
- func (d *Daemon) MergeProof(dir, ref, into string) (*MergeProof, error)
- func (d *Daemon) Merged(into string, branches []string) (*MergedResult, error)
- func (d *Daemon) OpenHome(id string) (any, error)
- func (d *Daemon) PreviewPort(port int) error
- func (d *Daemon) PublishTaskFunc() shared.PublishTask
- func (d *Daemon) QueueDispatch(body []byte) (any, error)
- func (d *Daemon) Recognise(url string) (*rules.Resolved, error)
- func (d *Daemon) ReconcilePRClaims()
- func (d *Daemon) RemoveHome(id string) (any, error)
- func (d *Daemon) RestartPtyHost(ctx context.Context, wait time.Duration, why string, immediate bool) (PtyHostReport, error)
- func (d *Daemon) RestartRunner(taskID string) (*store.Task, error)
- func (d *Daemon) Run(ctx context.Context) error
- func (d *Daemon) RunSourceNow(id string) (int, error)
- func (d *Daemon) SetHubLink(f func() any)
- func (d *Daemon) SetPRClaim(f func(ctx context.Context, ask api.PRClaimAsk) (api.PRClaimReply, error))
- func (d *Daemon) SetSSHWizard(f func(r *http.Request) any)
- func (d *Daemon) Settling() bool
- func (d *Daemon) Shelve(taskID string) error
- func (d *Daemon) StartFixtureNow(id string) error
- func (d *Daemon) StashTo(ctx context.Context, card, dir, branch string) (string, string, error)
- func (d *Daemon) StopRunner(taskID string) error
- func (d *Daemon) StopRunnerBy(taskID, by string) error
- func (d *Daemon) Store() *store.Store
- func (d *Daemon) Unshelve(taskID string) (started bool, why string, err error)
- func (d *Daemon) WaitActivity()
- type DiskDrive
- type DiskStatus
- type DiskUser
- type DiskView
- type Escalation
- type FinishRequest
- type FixtureFault
- type FolderSwept
- type HelpRequest
- type HomeInfo
- type HomeRemoved
- type HostFlag
- type HostStatus
- type Limit
- type LimitEvent
- type Location
- type LoginNeeded
- type MarkedCard
- type MergeProof
- type MergedResult
- type Options
- type OutsideCard
- type Peer
- type PermissionRequest
- type PermissionResponse
- type Prompt
- type PtyHostReport
- type Registry
- type RelayLaunch
- type RelayResult
- type RelaySay
- type RemoteEvent
- type RemotePeer
- type RemoteTask
- type RepliesView
- type Reply
- type ResumeBusy
- type Runner
- type SessionEvent
- type StampReply
- type Subagent
- type Telemetry
- type TelemetryEvent
- type UsageView
- type WrapReport
Constants ¶
const ( NoticeReport = "report" NoticeSilentStop = "silent-stop" NoticeLongTool = "long-tool" // NoticeLongTurn is one turn running past the long-turn setting. See // longTurn. NoticeLongTurn = "long-turn" // NoticeStuckWake is the one notice typed to a launcher that holds its notices, when a // card it launched has been stuck past the second step of the backoff. See wakeLauncher. NoticeStuckWake = "stuck-wake" // NoticeRoomGuess is a hook that found this room in daemon.json, once per card. See noteRoomGuess. NoticeRoomGuess = "room-guess" )
Notice sources. Each is one reason a launcher is told something, and each pairs with a key naming the one event that caused it. See RecordNotice.
const ( ReachTyped = "typed" ReachHook = "hook" ReachUnconfirmed = "unconfirmed" ReachNo = "no" )
How a message can reach a card.
const ( ActivityTool = "tool" ActivityIdle = "idle" // ActivityCompacting starts with PreCompact. There is no matching completion // hook, so clear it on the next activity event or after compactingFor. // This is transient activity; store.EventCompacted records the lasting event. ActivityCompacting = "compacting" )
Activity states. Status says what a card needs; these say what it is doing. Waiting is absent: the column and the wait chip already carry it.
const ( // HeldForLine is the operator's input line: text in it, or a keystroke in // the last `peerGateIdle`. Clearing or submitting the line lets it through. HeldForLine = "line" // HeldForTurn is the runner's turn. The message asked for `when: "done"`, // or the runner does not take input mid-turn. It goes when the turn ends. HeldForTurn = "turn" // HeldForDialog is a prompt the runner drew on its own screen, which an // Enter would answer. It goes once the dialog is answered. HeldForDialog = "dialog" // HeldForNewContext is a new-context cycle in progress. It holds every // message until its wake prompt has been typed. See newcontext.go. HeldForNewContext = "new-context" // HeldForDeploy is a room deploy hold. It holds another agent's messages // until the card's wake has been typed. See roomhold.go. HeldForDeploy = "deploy" )
What is holding a message, as HeldFor says it. Three conditions and each is cleared by something different, which is why the board names the one that applies rather than blaming the line for all of them.
const ( // HeldTurnAsked is the sender's own `when: "done"`. HeldTurnAsked = "asked" // HeldTurnRunner is a runner that does not take input mid-turn, which holds // every message for the turn whatever its sender asked. HeldTurnRunner = "runner" )
Whose rule a turn wait is, as HeldTurn says it. The board names the one that applies rather than offering both.
const ( DefaultCullInto = shared.DefaultCullInto KeepOpenTag = shared.KeepOpenTag )
What the cull and the card homes share, hoisted to shared so the home package needs no Daemon.
const ( DiskWarnDefault = 20 << 30 DiskCriticalDefault = 0 )
const ( DiskOK = "ok" DiskWarning = "warning" DiskCritical = "critical" )
const ( ReportDone = "done" ReportBlocked = "blocked" ReportQuestion = "question" ReportProgress = "progress" )
Report statuses. `done` and `needs-input` are what `atrium finish` has always taken. The other three are the worker contract.
const ( // WantBlocked is a session that stopped and asked. It cannot go on until // somebody answers, and there are words on the card saying what it needs. // // First because it is the only one that is both stopped and specific. WantBlocked = "blocked" // WantPermission is a session held at the permission gate. Also stopped, // and answered with a decision rather than with thought. WantPermission = "permission" // WantQuestion is `atrium ask --continue`: a question from a session that // is carrying on regardless. Worth an answer, never worth an interruption. WantQuestion = "question" // WantFinished is a session that declared its work over. It wants reading, // not answering. WantFinished = "finished" // WantQuiet is a session atrium has heard nothing from and that has said // nothing about itself. No recap, no question, no activity. // // THE ONE NOBODY LOOKS AT, which is why it ranks above the sessions that // are visibly working. A session that is fine and a session that died an // hour ago look identical from here, and that is the point: the only way // to find out is to go and look, and until now nothing said which ones to // go and look at. WantQuiet = "quiet" // WantWorking is a session that is moving and has asked for nothing. // Nothing to do about it. WantWorking = "working" )
What a card wants from you. Ordered by how much it wants it, which is the order the list comes back in.
FOUR OF THESE WERE REPEATEDLY CONFUSED, and telling them apart is the whole point: a session that finished and filed a recap, a session that stopped and asked a question, a session still working that asked one anyway, and a session that has gone quiet with nothing recorded. The last is the one nobody knows to look at, because it has never asked for anything.
const ( KindFYI = "fyi" KindNeeds = "needs" )
Kinds a report or a say may carry.
const ( HostHogPctDefault = 90 HostHogMinutesDefault = 5 )
const ( HostShapeHog = "hog" HostShapeSSHDBare = "sshd-no-tcp" )
const ( // ItemOwnerSilentAfter is how long an owner may leave a blocked item with no answer. ItemOwnerSilentAfter = 15 * time.Minute // ItemResumeAfter is how long a worker may take to resume once the answer is delivered, and again after it is // typed a second time. ItemResumeAfter = 2 * time.Minute // ItemStuckSource marks the alert on the card and its escalation. ItemStuckSource = "item-stuck" ItemStuckOwnerSilent = "owner-silent" ItemStuckOwnerGone = "owner-gone" ItemStuckWorkerStalled = "worker-not-resumed" )
const ( NoticeLaunchIdle = "launch-idle" NoticeLaunchPrompt = "launch-prompt" NoticeTerminalMenu = "terminal-menu" )
Escalation sources for a card stuck at its terminal.
const ( PromptFolderTrust = "folder-trust" PromptLogin = "login" PromptUpdate = "update" PromptSettings = "settings" PromptModelSwitch = "model-switch" PromptOther = "other" )
Escalation.Prompt for a launch-prompt: which prompt it is. `other` is a menu nobody knows, and its title is the escalation's Text. A terminal-menu says model-switch or other.
const ( LearningsMaxEntries = 50 LearningsMaxBytes = 20 * 1024 )
LearningsMaxEntries and LearningsMaxBytes are the cap. Either one reached is the cap reached.
const ( ViaTyped = "typed" ViaPrompt = "prompt" ViaPermission = "permission" ViaMessage = "message" ViaAction = "action" ViaEnable = "enable" ViaResume = "resume" )
The vias a human touch can carry.
const ( PromptOperator = promptline.PromptOperator PromptPeer = promptline.PromptPeer PromptCommand = promptline.PromptCommand )
Prompt kinds. See promptOf.
const ( WhenImmediate = shared.WhenImmediate WhenDone = shared.WhenDone )
const (
ActivityThinking = shared.ActivityThinking
)
What the context cycle shares with the rest of the room, hoisted to shared so the cycle package needs no Daemon.
const ArchiveWorkersDefaultAfter = 24 * time.Hour
ArchiveWorkersDefaultAfter applies when the setting was never written.
const ChatTag = "atrium:chat"
ChatTag marks a card launched with `chat: true`: a superlean session with no tools of its own and only atrium_need from atrium-control, which grows by atrium_need as `atrium:tool:<name>` tags.
const DecidedByHubAuto = "global-auto"
DecidedByHubAuto is the one decider a caller of the decide route may name: the hub's board-wide auto switch (r-020). Everything else a caller sends is refused, so no caller can forge a rule's name or another decider.
const DefaultIncomingKeepDays = 7
DefaultIncomingKeepDays is what an unset incoming_keep_days means.
const DefaultInterviewModel = "opus"
DefaultInterviewModel is the model an interview gets when the launch names none and worker_policy sets no interview_model.
const DirectorTag = "atrium:director"
DirectorTag marks a resident session that launches workers and waits on them.
const DispatchKeepSettled = 24 * time.Hour
DispatchKeepSettled is how long a finished queue item stays on the board.
A DAY, and the long end of the choice on purpose. A failed item IS the product here: it is the readable reason a launch did not happen on a machine nobody was watching, and clearing it after an hour would mean coming back in the morning to a queue that looks like nothing was ever wrong. An item that started is kept for the same length only because two rules is worse than one.
const ElevatedTag = "atrium:elevated"
ElevatedTag gives a worker card atrium_launch and atrium_launch_worker. The hub's class lookup reads it.
const EndReasonMax = 50
EndReasonMax is the longest reason atrium_blocked takes, in words.
const EscalatedBy = "held-escalation"
EscalatedBy names the card event that records an escalated message.
const HoldNoticesTag = "atrium:hold-notices"
HoldNoticesTag puts a launcher's automatic notices on its card instead of in its terminal. The orchestrator's rule, for any card that wants it without the rest of what OrchestratorTag means.
const InterviewTag = "atrium:interview"
InterviewTag marks a card launched with `kind: "interview"`. The interviewer's turn ends are its QUESTIONS to a human, so atrium never nudges it for stopping without a report, never calls it stuck for that, and never raises the launch-idle notice for it. It also gets the interviewer's system prompt, in place of the worker's. The hub puts it on (link.InterviewTag), and a test keeps the two equal.
const (
InvestigationTag = "atrium:investigation"
)
KeepOpenTag and InvestigationTag are the two tags that say a card is not closed by a done report and is never reclaimed. The launcher puts one on when the card is meant to outlive its first answer: a long conversation, or an investigation whose transcript is the product. See reclaim.go.
const ItemEndingLine = "Before you end your turn, call either:\n" +
"- atrium_done <sha or artifact> [one line] when the work is finished\n" +
"- atrium_blocked <up to 50 words> when something stops you, such as a question you need answered, a tool you need installed, or a permission you need.\n" +
"Then stop. Say nothing more.\n" +
"Run tests and builds in the foreground, with a longer command timeout if needed. If a command must run in the background, wait for it in the same turn. Never end a turn while a command you started is still running.\n" +
"A link for the human is ALWAYS a board link from atrium_link, never 127.0.0.1, localhost, a port, file:// or a new server. A mock is static files in your card with relative paths. Render it headless through that link and read the PNG before you report it. atrium_done, atrium_blocked and atrium_say refuse anything else.\n" +
"Your commit is read from your worktree or any hub branch, so never ask where to push and never offer a push to origin. If you are asked to stop, answer with atrium_done and your last sha."
ItemEndingLine is how an item worker is told to end. LaunchEndingLine without a launcher in it: an item worker is not told who asked for the work, because it has nobody to talk to but the tool that ends it. Kept equal to link.itemReportLine by a test in internal/link.
const ItemOwnerTag = "atrium:item-owner:"
ItemOwnerTag carries the owner an item launch asked for, as `atrium:item-owner:<spec>`. A tag because a tag already travels with a launch through every door, hub and room, and a new field would need plumbing through all of them.
const ItemTag = "atrium:item"
ItemTag marks a card launched with `item`: a task whose only routing is "tell whoever wanted it when it is done". The same tag as link.ItemTag.
STAGE 1 IS CONVENTION, NOT A TABLE. An item launch changes what the worker is told and what it can reach, and stores nothing new: the tag is the whole mark. An ordinary launch is unchanged in every way.
const LaunchEndingLine = "Before you end your turn, tell your launcher either:\n" +
"- atrium_done <sha or artifact> [one line] when the work is finished\n" +
"- atrium_blocked <up to 50 words> when something stops you, such as a question you need answered, a tool you need installed, or a permission you need.\n" +
"Then stop. Say nothing more.\n" +
"Run tests and builds in the foreground, with a longer command timeout if needed. If a command must run in the background, wait for it in the same turn. Never end a turn while a command you started is still running.\n" +
"A link for the human is ALWAYS a board link from atrium_link, never 127.0.0.1, localhost, a port, file:// or a new server. A mock is static files in your card with relative paths. Render it headless through that link and read the PNG before you report it. atrium_done, atrium_blocked and atrium_say refuse anything else.\n" +
"Report to your launcher, never to the operator, unless your launcher is the operator. Your commit is read from your worktree or any hub branch, so never ask where to push and never offer a push to origin. A launcher's \"stop\" is a valid end: answer it with atrium_done and your last sha."
LaunchEndingLine is how a launched session is told to end: the same text link.reportLine ends a launch prompt with, kept equal by a test in internal/link.
const LeanTag = "atrium:lean"
LeanTag marks a card launched lean, so a reopen or a resume starts it lean again. A tag rather than a column, the way OriginAgentTag is.
const LearnedMax = 1500
LearnedMax bounds one entry, in bytes: a paragraph.
const LearningsFile = "LEARNINGS.md"
LearningsFile is the file's name, in the card's directory.
const LearningsSource = "item-learnings"
LearningsSource names the alert's event on the card.
const LinkTagPrefix = "link:"
LinkTagPrefix marks a card a link opened (`link:<key>`, internal/api/open.go). Its lifetime is the link's: a done report does not end it, and only a close or the operator does.
const MaxAsk = store.MaxAsk
MaxAsk bounds what a session may say it needs.
Held in the store beside the column it bounds. Kept here as a name too, because this is where an agent-facing limit is read from.
const MergedGraceDefault = 30 * time.Minute
MergedGraceDefault is how long a merged worker stays before it is culled when the operator turns the automatic cull on by setting a grace. Unset, the setting is a day (store.DefaultMergedCullGrace), and `off` disables it.
const MinionTag = "atrium:minion"
MinionTag marks a per-item minion: a director that exits on its final done.
const MoveInReason = "adopted into atrium: this session is ending here and resuming under atrium's own terminal"
MoveInReason is what the held request is answered with when its session is moved into atrium.
const NoAutocompactNote = "runner does not take autocompact"
NoAutocompactNote is what the card details say for a runner that does not take the flag.
const NoticeBudget = "budget"
NoticeBudget is a worker past the budget. One per worker: the key never changes, so a card is told about once.
const NoticeFYI = "fyi"
NoticeFYI is the source of a held fyi, as `held notice` readers see it.
const NoticeNoLauncher = "report-no-launcher"
NoticeNoLauncher is the source of a held notice about a report that reached nobody.
const NoticeOwed = "owed"
NoticeOwed is the source of a held notice about an open item.
const NoticeSilentNudge = "silent-nudge"
NoticeSilentNudge is the claim that the worker was nudged, once per launcher prompt and nudge number.
const OrchestratorTag = "atrium:orchestrator"
OrchestratorTag marks the orchestrator card. It is its OWN rule and not the opt-in above: the orchestrator is where everything filters back, so it parks only when literally nothing else is running. Nothing wears it until the operator or the orchestrator puts it on a card.
const OriginAgentTag = "origin:agent"
OriginAgentTag marks a card that `atrium_launch` created. The hub adds it (see link.OriginTag, the same string) and the room stores it as an ordinary tag. Duplicated rather than imported because neither package imports the other, and a test pins the two together.
const ParkIdleTag = "atrium:park-idle"
ParkIdleTag once opted one of the operator's own cards into idle parking. It no longer does: only agent cards (`origin:agent`) are subject. It still asks for a handoff, see takesHandoff.
const PoolTag = "atrium:pool:"
PoolTag marks a card as a member of a pool: `atrium:pool:<name>`. Put it on a resident launch.
const PruneDefaultAfter = 30 * 24 * time.Hour
PruneDefaultAfter is the age offered when somebody turns it on, and not a default in the sense of applying to anybody who has not.
Thirty days, because this deletes the only account of what a session ran and what it was allowed to do. The right number is a deliberate answer to "how far back do I ever look", and the first number that seems large is not it.
const QuietAfter = 15 * time.Minute
QuietAfter is how long a card with no known process id may go without a word before it is treated as gone.
It was three hours, which is far too generous for what it is measuring. A card with no pid never reported one, so its session hook never ran, which makes it the kind of session atrium knows least about rather than the kind to give the most benefit of the doubt to. Meanwhile the board showed it as `running` for the rest of the afternoon, in the column that is supposed to mean something is working.
The cost of being early is a card that flips back to running the moment the session says anything, because any activity revives it. The cost of being late is a running column that cannot be trusted. Fifteen minutes: a session silent that long with nothing to check is not something to keep claiming is working, and if it was, it says so and comes straight back.
const ReapEvery = 20 * time.Second
ReapEvery is how often liveness is checked. The check is a syscall per card, so this can be frequent without costing anything meaningful.
const ResidentEndingLine = "You are resident: your card stays open between tasks. When a task is finished, call atrium_done <sha or artifact> [one line]. When something stops you, call atrium_blocked <up to 50 words>. Either one tells your launcher and leaves your card open. Then wait for the next message. Never call atrium_exit on yourself.\n" +
"Run tests and builds in the foreground, with a longer command timeout if needed. If a command must run in the background, wait for it in the same turn. Never end a turn while a command you started is still running.\n" +
"A link for the human is ALWAYS a board link from atrium_link, never 127.0.0.1, localhost, a port, file:// or a new server. A mock is static files in your card with relative paths. Render it headless through that link and read the PNG before you report it. atrium_done, atrium_blocked and atrium_say refuse anything else.\n" +
"Report to your launcher, never to the operator, unless your launcher is the operator. Never ask where to push."
ResidentEndingLine is how a resident card is told to end a task, kept equal to link.residentReportLine by a test in internal/link.
const ResidentTag = "atrium:resident"
ResidentTag marks a card that stays open between tasks: a done or a blocked reports a task and never ends it. The same tag as link.ResidentTag.
const ReviewTag = api.ReviewTag
ReviewTag marks a card launched with `kind: "review"`. Its turn ends are the human's to answer in the review view or in chat, so atrium never nudges it for stopping without a report and never raises the launch-idle notice for it.
const SettingArchiveWorkersAfter = store.SettingArchiveWorkersAfter
SettingArchiveWorkersAfter is how long a done worker card stays before the sweep archives it, in seconds.
const SettingCardRoot = cardroot.Setting
SettingCardRoot is the room's card root, where every home and task folder goes.
const SettingLandedReclaimGrace = store.SettingLandedReclaimGrace
SettingLandedReclaimGrace is how long a landed worker waits after its runner exits before it is pruned. Seconds, or `off`.
const SettingMergedCullGrace = store.SettingMergedCullGrace
SettingMergedCullGrace is the daemon setting. Seconds, or `off`.
const SettingPruneAfter = store.SettingPruneAfter
SettingPruneAfter is how old a finished card has to be before it is deleted outright, in seconds. `off`, which is the default, means never.
const SettingRunnerUpdateCheck = "runner_update_check"
SettingRunnerUpdateCheck set to `off` stops every registry lookup, for a machine that cannot reach the registry. Unset, or anything else, keeps the lookup on.
const SettingShellCommand = api.SettingShellCommand
SettingShellCommand names the shell to open, and it now lives in `internal/api` beside the other settings the board can write.
Moved rather than duplicated. It sat here, next to the only code that read it, which is the tidier arrangement and is exactly why nobody noticed it had never been added to the settings endpoint.
const SettingSweepDead = store.SettingSweepDead
SettingSweepDead turns it off. Stored as the number of seconds, so the setting is also the answer to "how long", and `off` is the one value that means never.
Defined in the store, because the HTTP layer names it too and cannot import this package.
const SpikePrefix = "s-"
SpikePrefix starts a spike item's id. A spike's done names the follow-ups it filed and puts its writeup on the hub.
const StampLogMax = 512 << 10
StampLogMax is the most of a log that is kept, in bytes. The tail is what a log is read for, so it is the tail that stays.
const StepTagPrefix = "atrium:step:"
StepTagPrefix starts the tag that says which step of its item a card is for, `atrium:step:<step>`: designed, approved, building and so on. It rides the card's first push to the hub, which files it on the attachment. A card with none is a builder. The same prefix as link.StepTagPrefix.
const SubagentTag = "atrium:subagent"
SubagentTag marks a worker an orchestrator launched to do one piece of work. The same string as `link.SubagentTag`, which the launch cap counts. The launcher puts it on, and only a card carrying it can be culled.
const SuperleanTag = "atrium:superlean"
SuperleanTag marks a card launched superlean, beside LeanTag: superlean implies lean, so everything that reads LeanTag keeps working. See docs/runtime/superlean-design.md.
const TaskTagPrefix = "atrium:task:"
TaskTagPrefix starts the tag that says a card runs a task of an item: `atrium:task:<tid>`.
const TypedQueued = "typed-queued"
TypedQueued is the answer for a line that was typed into a runner mid-turn and has not been read: it is in the runner's queued-message box. `terminal` is kept for a line typed into an idle runner, whose prompt submit is its read. Only a forced say can type mid-turn into a runner that queues, since nothing else does.
const VacuumEvery = 5 * time.Minute
VacuumEvery is how often freed pages are handed back to disk.
Modest on purpose. The event sink keeps the database from growing, so this only has to keep pace with pruning, not with writes, and each tick reclaims a bounded batch (store.IncrementalVacuumPages) so it never blocks a request for long. Off the hot path by construction: nobody is waiting on it.
const WorkTagPrefix = "atrium:item:"
WorkTagPrefix starts the tag that attaches a card to an item, `atrium:item:<backlog id>`. It is NOT ItemTag: that is whole-string and means isolated, and this one only ever has an id after it. The same prefix as link.WorkTagPrefix. The room tells the hub on launch and on every restart of the card, because the tag is on the card and a restart changes the generation and never the attachment.
Variables ¶
var ( // SilentStopNotifyAfter is how long a stop may go unreported before the // watchdog tells the launcher, for a session whose Stop hook did not // already. With the hook the notice is sent as the turn ends. SilentStopNotifyAfter = envDuration("ATRIUM_A2A_SILENT_STOP", 2*time.Minute) // LongToolAfter is how long one tool call may run before it counts as // stuck. It cannot tell a hung process from a long build, so it reports and // never kills anything. LongToolAfter = envDuration("ATRIUM_A2A_LONG_TOOL", 20*time.Minute) // BackgroundHoldMax is how long background work named by a Stop holds the // silent-stop alert. A build finishes and wakes the session well inside it. // A dev server left running never does, and must not hide a real stop forever. BackgroundHoldMax = envDuration("ATRIUM_A2A_BACKGROUND_HOLD", 2*time.Hour) )
The thresholds. Each has an environment override that takes a Go duration, and a value that does not parse is ignored, the same rule `launchCap` uses.
var ( DiskWatchEvery = time.Minute DiskWatchStart = 10 * time.Second DiskReclaimEvery = 5 * time.Minute DiskTempAge = 24 * time.Hour )
var ( FolderSweepEvery = 10 * time.Minute FolderSweepStart = time.Minute )
FolderSweepEvery is how often the sweep runs, and FolderSweepStart how long after the room starts it first runs.
var ( HostWatchEvery = 30 * time.Second HostWatchStart = 20 * time.Second )
var ( ErrRelayDown = hublink.ErrRelayDown ErrRelayOld = hublink.ErrRelayOld ErrRelayUnconfirmed = hublink.ErrRelayUnconfirmed )
var ( IncomingSweepStart = 30 * time.Second IncomingSweepEvery = time.Hour )
var ( // LaunchIdleAfter is the grace before a card nobody has heard from is called // idle since launch. LaunchIdleAfter = envDuration("ATRIUM_A2A_LAUNCH_IDLE", 60*time.Second) // LaunchPromptAfter is how long a pty must be quiet before a launch prompt // is believed. A trust dialog appears at once and does not move. LaunchPromptAfter = envDuration("ATRIUM_A2A_LAUNCH_PROMPT", 5*time.Second) // TerminalMenuAfter is how long a menu must sit, with the pty quiet, before // it is a blocker. Also the quiet launch-idle asks for. TerminalMenuAfter = envDuration("ATRIUM_A2A_TERMINAL_MENU", 30*time.Second) )
A claude card stuck on something only a person can answer, found from its terminal. Three escalation sources, all on the one Escalation the board draws:
- launch-idle: no hook has fired since the runner started, past a grace.
- launch-prompt: no hook yet, and the screen shows a prompt claude draws before its first turn (folder trust, login, update), or a menu nobody expected.
- terminal-menu: at any point in a card's life, a selection menu on the screen with the pty gone quiet. The trigger was a director that sat about 3.8 hours on "Model switch" while nobody told the operator.
ALL OF IT IS DERIVED EACH TICK, never stored: the first hook after the launch, or the menu being answered, ends it with nothing to clear.
THE SCAN COSTS NOTHING ON A BUSY CARD. A pty that spoke recently is not looked at (one atomic read), and a quiet one is rendered once per distinct last-output time, then answered from the memo until it speaks again.
var BusyCard = cycle.BusyCard
var ContractVersions = []int{1}
ContractVersions are the runner contract versions the room answers. v1 only ever gains optional fields.
var DefaultLocationPath = roomconf.DefaultLocationPath
var EndedFolderGrace = ArchiveWorkersDefaultAfter
EndedFolderGrace is how long a done or dead card that is still on the board keeps its folder, the window in which a launcher sends the work back. An archived card has none.
ErrHubDictateUnavailable marks a hub that cannot transcribe right now: down, older than the kind, or with speech to text off. The room then tries its own whisper before it says why not.
var EscalationBackoff = []time.Duration{ time.Minute, 2 * time.Minute, 5 * time.Minute, 10 * time.Minute, 30 * time.Minute, time.Hour, 2 * time.Hour, 4 * time.Hour, 8 * time.Hour, 24 * time.Hour, }
EscalationBackoff is when the board is told again about a worker that is still stuck, measured from the moment it became stuck. The operator's own schedule. Past the last step it repeats every 24 hours. It resets when the card moves, because a card that moved is a new situation.
The board's permission nag in notify.js follows the same schedule, so a permission, a silent stop and a stuck tool all ring on one rhythm.
var FinishedWorkerGrace = time.Hour
FinishedWorkerGrace is EndedFolderGrace for a worker that reported done, so a finish frees its disk the same day.
var LocalServeEvery = 30 * time.Second
LocalServeEvery is how often the room checks the servers in `local_servers`.
var LocationPath = roomconf.LocationPath
var LooksIdleAfter = shared.LooksIdleAfter
LooksIdleAfter is how long a pty must be silent before the frame is looked at. Twenty-odd missed spinner redraws. The check rides the reaper's tick, so a firing lands this long after the turn ended, plus up to one tick.
var OrphanGrace = 3 * time.Minute
OrphanGrace is how long a pending request may go unmatched before it is treated as orphaned.
Not zero, because the two facts are read at different moments. A request recorded a millisecond ago may not have reached the hub's map yet, and a daemon that restarted has a store full of pending requests and an empty map until every agent reconnects on its own backoff, which runs to a minute. A variable rather than a constant so a test can be on the other side of it without waiting three minutes. Nothing in production writes to it.
var ReadLocation = roomconf.ReadLocation
var RepoIsRef = home.RepoIsRef
What the home package declares and the CLI reaches as daemon.X.
var RoomDataNames = []string{store.LedgerFileName, reopenFile, carryDirName, "reviews", "icons", "cards", "lean-plugins", "docshares", "identities", "zrok", cycle.HandoffDirName}
RoomDataNames is everything a room keeps beside its database, which `atrium room move` carries with it. A name the daemon joins onto filepath.Dir(DBPath) belongs here, except scrap, which is emptied on every start.
var SweepDeadAfter = time.Minute
SweepDeadAfter is how long a dead card stays before it is deleted.
Short, because there is nothing to come back for: a session that revives says so and gets its card back, and one that does not was over.
Not zero. A card that vanished the instant it died would take the reason with it, and the reason is the one thing worth reading on a dead card: a runner that failed to start puts its last output there. A minute is long enough to see it and short enough not to accumulate.
var TerminalTemplate = defaultTerminal()
TerminalTemplate wraps a command so it opens in a real terminal window. {cwd}, {title} and {cmd} are substituted. Configurable because which terminal you want is a preference, not a property of atrium.
Windows Terminal is tried first and falls back to cmd, so this works on a bare machine too.
var WokenGuard = 10 * time.Minute
WokenGuard is how long after a card was woken, resumed or last active its folder is safe from the sweep.
Functions ¶
func BriefPrompt ¶
BriefPrompt is the launch text of a session with a brief file: read it, do what it describes, and how to end. ONE CODE for the room's launch and the stdio atrium_launch. A launcher's prompt that only says to read the brief and do it is not repeated after "Then:", and the ending is never doubled.
func CheckBlockedReason ¶
CheckBlockedReason is why a reason for atrium_blocked is refused, or "": 1 to 50 words, split on whitespace.
func CountCards ¶
countCards reads how many cards a database holds, without migrating it.
Read-only and deliberately hand-rolled rather than going through the store: opening the OTHER database through `store.Open` would run every migration against it, which is a write, and writing to a database the operator did not ask this daemon to touch is exactly the wrong way to tell them they have two.
Any failure answers -1, which reads as "could not say" rather than "empty". A missing file, a locked one and a schema that predates the task table all land here and none of them is worth a second warning. CountCards is the number of cards in the database at path, read only, or -1 when it cannot be read.
func DefaultDBPath ¶
func DefaultDBPath() string
DefaultDBPath puts the database next to the rest of atrium's state.
func EndsTheSession ¶
EndsTheSession reports whether a SessionEnd reason is really the end.
`clear` and `resume` are both followed immediately by a SessionStart in the same directory, so treating either as a death makes the card go to finished and come straight back, which on the board is a card flickering out of the column you were reading.
Everything else, including an unset reason, IS an ending. A runner that says nothing has not claimed the session is continuing, and a card left in running forever is the worse mistake of the two.
Exported and used by the hook as well as by the daemon, so the two cannot disagree about what an ending is.
func EnrollZitiInto ¶
EnrollZitiInto is publish.EnrollZitiInto, kept here for the CLI.
func IsAskingTool ¶
IsAskingTool reports whether a tool call is the model asking you something.
func ItemBriefPrompt ¶
ItemBriefPrompt is BriefPrompt for an item, which closes on ItemEndingLine.
func PromptToolNames ¶
func PromptToolNames() []string
PromptToolNames is every atrium_* tool the lean worker prompt and the interviewer prompt name, sorted. A test on each control path keeps the set a lean worker is served a superset of it.
func ResidentBriefPrompt ¶
ResidentBriefPrompt is BriefPrompt for a resident card, which closes on ResidentEndingLine.
func ResolveItemOwner ¶
ResolveItemOwner is resolveItemOwner for a test that holds it equal to the hub's.
func StateDir ¶
func StateDir() string
StateDir returns the directory atrium keeps its own state in: a hub folder under WORKTREE_ROOT when that is set, otherwise ~/.atrium.
No hardcoded drive path. One machine's layout is not a default for another, and a home directory exists everywhere.
The `hub` segment stays. It is where every existing database with WORKTREE_ROOT set already lives, and a daemon that opens a new empty database shows a board that has lost every card.
func ToolLocations ¶
ToolLocations is toolLocations on this process's PATH, for the room's hello.
Types ¶
type ActionResult ¶
type ActionResult struct {
// Delivered is "terminal" or "queued", the same two words the message
// endpoint uses, because they are different promises and the board has to
// say which one it made.
Delivered string `json:"delivered"`
// Exiting is whether the runner was also asked to leave.
Exiting bool `json:"exiting"`
// Note carries anything the operator should know, such as an exit that
// could not be attempted.
Note string `json:"note,omitempty"`
}
ActionResult is what happened when an action ran.
type Activity ¶
type Activity struct {
// What is one of the Activity constants.
What string `json:"what"`
// Tool is the tool being run, when What is ActivityTool.
Tool string `json:"tool,omitempty"`
// Subagents currently running under this session.
//
// A count, kept because it is what the badge shows and because a hook that
// went missing can leave the named list short without making the number
// wrong in a way anybody would notice.
Subagents int `json:"subagents"`
// Running names them, when the runner says who they are. Claude Code's
// SubagentStart carries an agent id and a type, so "3 subagents" can be
// "explore, review, review" instead. Oldest first, which is the order they
// were started in and the order they will mostly finish in.
//
// May be shorter than Subagents. A runner that reports no id still moves
// the count, and the count is the thing that must not lie.
Running []Subagent `json:"running,omitempty"`
// Dialog says the runner has put a prompt on its own screen that atrium
// did not raise, so nothing may type into that terminal.
//
// `runner.Say` writes the text and then writes Enter. An Enter landing on
// a dialog answers it with whatever option was highlighted, and nothing
// reports that it happened: the operator sees a message they sent, and
// separately a tool call approved by nobody.
//
// IN MEMORY AND NEVER WRITTEN DOWN, like everything else here. It is true
// of a process rather than of a card, and it would be a lie the moment the
// daemon restarted. See docs/runtime/activity-design.md.
Dialog bool `json:"dialog,omitempty"`
// HeldPeer names the session whose message is waiting to be typed into this
// terminal, empty when nothing is held. HeldSeconds is how long it has
// waited.
//
// NOT SUBJECT TO THE STALENESS CUTOFF, unlike everything else here. The rest
// is about a running process and expires when the hooks go quiet. A held
// message is a fact about a queued injection, and it stays true while the
// operator's line is dirty however long that runs, which is exactly when the
// process is idle and the rest of this has expired. See the held map and
// `pendingInjector`.
HeldPeer string `json:"held_peer,omitempty"`
HeldSeconds int64 `json:"held_seconds,omitempty"`
// HeldFor is what is holding the oldest message: one of the HeldFor
// constants. HeldCount is how many are held, which the chip shows.
HeldFor string `json:"held_for,omitempty"`
HeldCount int `json:"held_count,omitempty"`
// HeldTurn says whose rule a turn wait is, when HeldFor is the turn: one of
// the HeldTurn constants. The board names that one reason.
HeldTurn string `json:"held_turn,omitempty"`
// HeldQuiet is a hold that is only the message waiting as it was meant to:
// every held message waits for the turn, and none has waited past
// `heldTurnPatience`. The board draws a quiet queued mark for it and not the
// `!`, which is kept for a message held against what its sender asked for.
// Decided here and not on the board, so there is one rule. See heldPeer.quiet.
HeldQuiet bool `json:"held_quiet,omitempty"`
// HeldStuck is a hold that has outlasted heldStuckAfter without being typed, whatever holds it. See
// pendingInjector.flagStuck.
HeldStuck bool `json:"held_stuck,omitempty"`
// HeldEscalateMin is escalate_held_after in minutes, set on a turn wait: a `when: done` message goes in when the
// turn ends or after this long, whichever is first, and the board's tip says so. See escalate.go.
HeldEscalateMin int `json:"held_escalate_min,omitempty"`
// LooksIdle says the card reads running but its terminal has gone quiet on an
// idle prompt, so the turn-end never arrived. A guess, drawn as one.
// IdleSeconds is how long the pty had been silent when it was decided. IN
// MEMORY like the rest, cleared by any hook event, output or keystroke. See
// looksidle.go.
LooksIdle bool `json:"looks_idle,omitempty"`
IdleSeconds int64 `json:"idle_seconds,omitempty"`
// IdleAt is when it was flagged, which keys the board's alert so each firing
// rings once.
IdleAt time.Time `json:"idle_at,omitzero"`
// Panel says the session started the review-panel skill this turn. Cleared when the turn ends, and gone with the
// rest of this on a session end, a restart or the staleness cutoff, so a crash cannot hold it. See notePanel.
Panel bool `json:"panel,omitempty"`
// Since is when this state began, so a card can say how long a tool has
// been going.
Since time.Time `json:"since"`
// Seconds is Since as an age, filled in when the activity is served.
Seconds int64 `json:"seconds"`
}
type ActivityEvent ¶
type ActivityEvent struct {
// Contract is the runner contract version the sender speaks. Absent means 1.
Contract int `json:"contract,omitempty"`
Agent string `json:"agent"`
TaskID string `json:"task_id,omitempty"`
// NameSource is "dir" when Agent was made up from the directory. Absent from
// a hook older than the field, which is read as a told name. Nothing here
// acts on it yet: activity only looks a card up.
NameSource string `json:"name_source,omitempty"`
// PID is the runner the hook found above itself, 0 when it found none.
PID int `json:"pid,omitempty"`
// Event is tool-start, tool-end, prompt, subagent-start, subagent-end,
// idle or waiting.
//
// idle and waiting both mean the agent stopped and it is the operator's
// move: idle from a turn ending, waiting from the Notification hook, which
// fires when claude has been sitting on a prompt. Both move the card to
// needs-input, which is what makes that column mean anything.
Event string `json:"event"`
// Tool is the tool name on a tool-start.
Tool string `json:"tool,omitempty"`
// AgentID and AgentType name a subagent, on subagent-start and
// subagent-end. Empty on everything else, and empty from a runner that
// does not report them, which costs the name and not the count.
AgentID string `json:"agent_id,omitempty"`
AgentType string `json:"agent_type,omitempty"`
// Notification is which kind of Notification hook fired, on a `waiting`.
// Empty on everything else and empty from a runner that does not send it.
//
// The one value acted on is `permission_prompt`, which says a dialog is on
// that terminal's screen. See dialogRaised.
Notification string `json:"notification,omitempty"`
// MissingTool is a known tool a shell answered command not found for, on a tool-end.
MissingTool string `json:"missing_tool,omitempty"`
// File is the file a Write, Edit or NotebookEdit changed, on a tool-end. See recordFileArtifact.
File string `json:"file,omitempty"`
FileChange string `json:"file_change,omitempty"`
FileAdd int `json:"file_add,omitempty"`
FileDel int `json:"file_del,omitempty"`
// RoomSource is "daemon.json" when the hook guessed this room from the machine's file and not from its env.
RoomSource string `json:"room_source,omitempty"`
// Skill is the skill a Skill call or a typed slash command starts, on a tool-start or a prompt.
Skill string `json:"skill,omitempty"`
}
ActivityEvent is what a hook posts to /activity.
type ActivityTracker ¶
type ActivityTracker interface {
// contains filtered or unexported methods
}
ActivityTracker is what the rest of the room asks of the activity tracker. The features that leave the package take this and never the struct.
type ArchiveWorkersResult ¶
type ArchiveWorkersResult struct {
DryRun bool `json:"dry_run"`
Archived []ArchivedWorker `json:"archived"`
Kept int `json:"kept"`
}
ArchiveWorkersResult is what one run did. DryRun means nothing was changed and Archived lists what would have been.
type ArchivedWorker ¶
ArchivedWorker is one card the tidy archived, or would.
type AutoDecision ¶
AutoDecision is the permission chain's answer to a request that never reaches a human: a replay, a message, a paused card, a rule, auto mode.
type Autocompact ¶
type Autocompact struct {
LimitK int `json:"limit_k"`
WindowK int `json:"window_k,omitempty"`
// CompactsK is where the session really compacts, which is what the peek shows.
CompactsK int `json:"compacts_k,omitempty"`
// Note is set when the runner does not take the flag.
Note string `json:"note,omitempty"`
}
Autocompact is the card details' numbers: the limit, the value the runner is started with and where it really compacts.
type BackfillResult ¶
type BackfillResult struct {
Cards, Rows, Replies int
// Skipped is cards with a resume id and no transcript on this machine.
Skipped int
}
BackfillResult is what a backfill did, or would do.
func BackfillUsage ¶
func BackfillUsage(st *store.Store, since time.Time, dry bool, transcript func(cwd, id string) string) (*BackfillResult, error)
BackfillUsage writes the rows the room missed for every Claude card, from since, held to store.UsageMaxBack. With dry true it counts and writes nothing. transcript is api.TranscriptPath when nil.
type BudgetView ¶
type BudgetView struct {
SpentUSD float64 `json:"spent_usd"`
BudgetUSD float64 `json:"budget_usd"`
Text string `json:"text"`
}
BudgetView is what a card past its budget shows.
type ContextSize ¶
type ContextSize struct {
Tokens int64 `json:"tokens"`
// Warn is whether it is at or past the card's limit, worked out here so the
// board and the trigger cannot disagree about the line.
Warn bool `json:"warn"`
// ThresholdK is the card's limit in thousands, 0 for none.
ThresholdK int `json:"threshold_k"`
// Source is the layer ThresholdK came from: "card", "hub" or "default".
Source string `json:"source"`
// Cycle is whether atrium cycles this card's context at the limit.
Cycle bool `json:"cycle"`
// OwnK is the card's own limit as stored, 0 when it has none, so the board can show and clear it.
OwnK int `json:"own_k,omitempty"`
// CeilingK is the most the card's runner leaves room for, 0 when atrium cannot tell.
CeilingK int `json:"ceiling_k,omitempty"`
// WantedK and WantedFrom are the limit the card would have had without the ceiling, set only when the
// ceiling cut it (Source is then "runner").
WantedK int `json:"wanted_k,omitempty"`
WantedFrom string `json:"wanted_from,omitempty"`
// Low says so when the limit is more than a quarter under the built-in default, and from where, so a card
// held to a small limit shows it from its first read and not only when the cycle fires. Empty otherwise.
Low string `json:"low,omitempty"`
}
ContextSize is a card's context as the board reads it.
type CullResult ¶
type CullResult = shared.CullResult
type Daemon ¶
type Daemon struct {
// Service is the published board. See overlay_service.go.
*publish.Service
// Publish sends one card to the board. See publishCard.
Publish func(id string)
// contains filtered or unexported fields
}
Daemon owns the store and both listeners.
func New ¶
New opens the store and builds the daemon. A storage failure here is fatal by design: the daemon refuses to start rather than run without durable state.
func (*Daemon) ArchiveWorkers ¶
func (d *Daemon) ArchiveWorkers(dryRun bool) (*ArchiveWorkersResult, error)
ArchiveWorkers archives every done worker card with no live runner.
func (*Daemon) BoardHandler ¶
Run serves both listeners until ctx is canceled or a listener fails. BoardHandler is the human-facing surface: the JSON API, the event stream, the terminal websocket and the board's own files.
EXPORTED SO A ROOM CAN SERVE IT SOMEWHERE ELSE. `internal/link` runs this same handler on connections the room dialled out to a hub, which is how the board can be restarted without touching a single running agent. It is the same handler the loopback listener uses, not a copy and not a subset: a room whose hub is down is still a working atrium on its own address, and that is the escape hatch the whole split depends on.
NOT the agent listener. That one is a different mux on a different port and `docs/fabric/overlays.md` says never to publish it. See `Run` below.
func (*Daemon) CancelDispatch ¶
CancelDispatch withdraws an item nobody has taken yet.
func (*Daemon) CancelPending ¶
CancelPending answers every outstanding request on a task with a block.
Moving a card out of a waiting state has to answer the question, not just hide it. Otherwise the agent stays frozen with nobody coming, and the request sits in the queue to be approved later against a situation that has moved on.
func (*Daemon) CloseShell ¶
CloseShell ends a card's shell now, if it has one.
Called when the card goes: archived, deleted, or swept. A pty holding a working directory open after its card is gone is a process nothing on the board accounts for, and on Windows it also locks the directory against the removal that is usually the next thing to happen. IT WAITS FOR THE PROCESS TO ACTUALLY GO, and that is not tidiness.
Closing the terminal is a hangup, not a kill, so the shell runs on for a moment with the card's directory as its working directory. On Windows that directory cannot be removed while any process sits in it, and deleting a card is often followed by removing the tree. Returning early makes that failure land somewhere else, worded as a permission error, with nothing connecting it to the shell.
Escalation, in the same order and for the same reason as `windDown`: hang up, wait, then kill. The wait is shorter because a shell has no work in flight.
func (*Daemon) Cull ¶
func (d *Daemon) Cull(taskID, into string) (*CullResult, error)
Cull asks a merged worker to leave and removes its worktree and branch. See the top of this file for what it refuses.
func (*Daemon) CullProved ¶
func (d *Daemon) CullProved(taskID, into, tip string) (*CullResult, error)
CullProved is Cull with a merge proof made elsewhere. `tip` is the commit the area branch was checked to contain, and this room's worktree has to be sitting on exactly it, because the proof was made where the area branch lives. Empty means the proof is made here, against a branch of this repository.
func (*Daemon) DiskCheck ¶ added in v0.0.4
func (d *Daemon) DiskCheck() DiskStatus
func (*Daemon) DiskNotice ¶ added in v0.0.4
func (*Daemon) DiskReclaim ¶ added in v0.0.4
func (*Daemon) DiskView ¶
DiskView is the homes sorted by size, the folders under the root that have no row, and the cards working outside it.
func (*Daemon) Dispatches ¶
Dispatches is the queue, for the board.
func (*Daemon) EnsureShell ¶
EnsureShell starts a shell for a card if there is not already a live one.
IDEMPOTENT ON PURPOSE. The board asks for a shell every time somebody presses the button, because the alternative is the board tracking which cards have one and being wrong about it after a restart. Asking twice returns the same terminal, which is what the operator meant both times.
func (*Daemon) HoldCull ¶
HoldCull is the hold: `atrium_cull hold=true` and the chip's keep. The mark goes and nothing marks the card again.
func (*Daemon) HostNotice ¶ added in v0.0.5
HostNotice is the room's runaway lines for the hub, "" while nothing is flagged.
func (*Daemon) HubDeleteBranch ¶
HubDeleteBranch is api.Server.HubDelete.
func (*Daemon) HubRefreshBranch ¶ added in v0.1.0
HubRefreshBranch is api.Server.HubRefresh.
func (*Daemon) Kill ¶
Kill stops the runner behind a card. A window-mode launch has no pid atrium owns, so it takes the one its hook last reported.
func (*Daemon) Launch ¶
Launch starts a runner, holding the card's and the resume's launch lock across the whole call so its check-then-spawn region is atomic against another caller. See keyedmutex.go: without this two launches onto one card, or two resumes of one conversation, both pass the liveness guard before either registers and both spawn.
RestartRunner holds the same lock itself and calls launchLocked, so a restart and a launch onto the same card serialize rather than braid.
func (*Daemon) LoginNeededReason ¶
LoginNeededReason is the flag's sentence for the link's beat, "" when it is down.
func (*Daemon) MergeProof ¶
func (d *Daemon) MergeProof(dir, ref, into string) (*MergeProof, error)
MergeProof checks `ref` against `into` in the repository of `dir`, which has to be the worktree of a card on this room. That is the whole containment rule: this is not a way to ask git about any directory on the machine.
func (*Daemon) Merged ¶
func (d *Daemon) Merged(into string, branches []string) (*MergedResult, error)
Merged marks the finished workers a merge into `into` covered. The candidates are workers whose launcher's worktree is on `into`, or every worker when `into` is claude/main. Each is checked with the same read Cull makes. `branches`, when given, limits it to workers whose branch is one of those.
func (*Daemon) OpenHome ¶
OpenHome shows a home's folder in the file manager of the machine the room runs on, by the ledger row's id. Argv and never a shell, and only a folder homeGuard accepts.
func (*Daemon) PreviewPort ¶ added in v0.0.4
PreviewPort is whether the hub may forward to this loopback port: never one of this room's own listeners, and none before they are bound. See api.Server.PreviewPort.
func (*Daemon) PublishTaskFunc ¶
func (d *Daemon) PublishTaskFunc() shared.PublishTask
PublishTaskFunc is Publish as the value a feature package takes in place of the Daemon.
func (*Daemon) QueueDispatch ¶
QueueDispatch files a launch for another machine.
NOTHING HERE IS CHECKED AGAINST THIS MACHINE. The harness id belongs to the room's harness table and the directory, if one is given at all, belongs to the room's filesystem. Validating either against what is configured here would refuse a correct dispatch because cdaws has a runner this desktop does not, which is the normal case rather than the exception.
The room name is not checked against the rooms that have checked in either. A machine that is switched off right now is a machine you can still queue work for, and it collects the queue when it comes back. That is most of the point.
func (*Daemon) Recognise ¶
Recognise resolves one URL against the recogniser table.
Returns rules.ErrNoRecogniser when no row wanted it, which the caller reports as "nothing recognises this" rather than as a broken request. Every other difficulty comes back INSIDE the resolution: a fetch that failed, a placeholder nothing filled in, a directory that is not there. All three are things a human reads and acts on, and none of them is a reason to withhold the four fields that did resolve.
func (*Daemon) ReconcilePRClaims ¶
func (d *Daemon) ReconcilePRClaims()
ReconcilePRClaims asks the hub about the PR rows made while it could not be reached. The room's attach calls it.
func (*Daemon) RemoveHome ¶
RemoveHome is the Disk view's remove button: the ledger row's id, never a path, and the removal of reclaimHome with the checks on the work skipped. It is the one caller that may skip them, and only for a home that is kept or orphaned.
func (*Daemon) RestartPtyHost ¶
func (d *Daemon) RestartPtyHost(ctx context.Context, wait time.Duration, why string, immediate bool) (PtyHostReport, error)
RestartPtyHost restarts this room's pty host and reopens the cards that had a runner in it.
func (*Daemon) RestartRunner ¶
RestartRunner asks a card's runner to exit, waits for it to be gone, and starts the same conversation again on the SAME card.
func (*Daemon) RunSourceNow ¶
RunSourceNow runs one source outside its interval.
A source is a script somebody just wrote, and the question they have is whether it works. Waiting fifteen minutes to find out that a path was wrong is how a feature goes unused.
A disabled source still runs when asked. Pressing the button IS the operator saying to run it, and refusing on the grounds that it is switched off would leave no way to test one before turning it on.
func (*Daemon) SetHubLink ¶
SetHubLink says how to read the state of this room's link to its hub, for GET /v1/hub-link.
func (*Daemon) SetPRClaim ¶
func (d *Daemon) SetPRClaim(f func(ctx context.Context, ask api.PRClaimAsk) (api.PRClaimReply, error))
SetPRClaim gives the PR door its way to the hub's claim table. Called once the link is built, as SetHubGit is. Nil is a room with no hub.
func (*Daemon) SetSSHWizard ¶
SetSSHWizard says how to run the ssh wizard's read only checks, for GET /v1/ssh/wizard.
func (*Daemon) Settling ¶
Settling reports whether this daemon is still bringing back what it had.
Read by `/v1/health`, which is the one thing every page already asks on a timer, so this needs no endpoint and no event of its own.
func (*Daemon) Shelve ¶
Shelve puts a card down and stops its runner.
The card, its history and its resume id all stay. Requests already waiting are answered by the caller before this runs, since a paused card is a standing no and leaving a question pending would freeze the agent behind a card nobody is looking at.
func (*Daemon) StartFixtureNow ¶
StartFixtureNow brings one up on demand, so a definition can be tried without restarting the daemon to find out whether it works.
The failure is returned here rather than swallowed. This is one fixture somebody just pressed start on, so there is a person waiting to hear, which is the opposite of the boot case.
func (*Daemon) StopRunner ¶
StopRunner asks a runner to exit the way its harness says to, without shelving the card.
The alternative was attaching, typing whatever that runner wants, and waiting. Terminate exists for when that does not work: it kills the process outright. This one asks.
func (*Daemon) StopRunnerBy ¶
StopRunnerBy is StopRunner with who asked, so the exit says it was asked for.
func (*Daemon) Unshelve ¶
Unshelve picks a paused card back up, starting its runner again from where the conversation left off.
Returns the reason when it cannot, so the caller can move the card anyway and say why nothing started. Failing to relaunch must not leave the card stuck in paused: the operator asked for it back.
func (*Daemon) WaitActivity ¶ added in v0.1.0
func (d *Daemon) WaitActivity()
WaitActivity returns once every detached onActivity has finished, for a test that closes the store next.
type DiskStatus ¶ added in v0.0.4
type DiskStatus struct {
Level string `json:"level"`
Say string `json:"say,omitempty"`
Notice string `json:"notice,omitempty"`
FreedBytes int64 `json:"freed_bytes"`
FreedAt time.Time `json:"freed_at,omitempty"`
Warn uint64 `json:"warn_bytes"`
Critical uint64 `json:"critical_bytes"`
Drives []DiskDrive `json:"drives"`
}
type DiskView ¶
type DiskView struct {
Root string `json:"root"`
FreeBytes uint64 `json:"free_bytes"`
TotalBytes uint64 `json:"total_bytes"`
Bytes int64 `json:"bytes"`
Error string `json:"error,omitempty"`
Homes []HomeInfo `json:"homes"`
NotAtriums []string `json:"not_atriums"`
Outside []OutsideCard `json:"outside"`
}
type Escalation ¶
type Escalation struct {
// Source is `silent-stop`, `long-tool`, `long-turn`, `launch-idle`,
// `launch-prompt` or `terminal-menu`.
Source string `json:"source"`
// Prompt names which prompt a launch-prompt or terminal-menu is stuck at:
// folder-trust, login, update, settings, model-switch or other. Empty otherwise.
Prompt string `json:"prompt,omitempty"`
// Since is when it became stuck. The backoff counts from here.
Since time.Time `json:"since"`
// Count is how many steps of the backoff have passed.
Count int `json:"count"`
// Minutes is how long it has been stuck, for the notice.
Minutes int `json:"minutes"`
// Text is the notice, worded here so the board says what the room knows.
Text string `json:"text"`
}
Escalation is a worker the board should hear about, served on the card. The board rings each time Count goes up.
type FinishRequest ¶
type FinishRequest struct {
// Contract is the runner contract version the sender speaks. Absent means 1.
Contract int `json:"contract,omitempty"`
// Agent is the wire name, the same one every hook uses.
Agent string `json:"agent"`
// TaskID is used when the session was launched by atrium and told which
// card it belongs to, which is more reliable than a name.
TaskID string `json:"task_id,omitempty"`
// Recap is what it did, in its own words. Optional for a human's session,
// and the card says so when it is missing rather than inventing one.
Recap string `json:"recap,omitempty"`
// Status is where to put the card. `done` unless something says
// otherwise. `needs-input` hands the work back without claiming it is
// finished. `blocked`, `question` and `progress` are a worker reporting.
Status string `json:"status,omitempty"`
// SHA is the commit a `done` names. Required for an agent-launched card
// unless NoCommit says why there is none.
SHA string `json:"sha,omitempty"`
NoCommit string `json:"no_commit,omitempty"`
// Artifact is what an atrium_done with no commit names instead: a path on this room or a URL.
Artifact string `json:"artifact,omitempty"`
// Ask is what a `blocked` or `question` needs. Required for both.
Ask string `json:"ask,omitempty"`
// Kind is `fyi` or `needs`. See fyi.go. Anything but fyi is needs.
Kind string `json:"kind,omitempty"`
// Ended is a worker ending with atrium_done or atrium_blocked: one line, and the work is over either way, so a
// blocked report moves its item to reported as a done one does. See ledgerReport.
Ended bool `json:"ended,omitempty"`
// Learned is one paragraph a pool card leaves for its pool with a done, appended to LEARNINGS.md. Ignored for any
// card that is not in a pool. See learnings.go.
Learned string `json:"learned,omitempty"`
// Why is why a task of an item did it the way it did, carried to the task's result. Ignored for any other card.
Why string `json:"why,omitempty"`
// Skipped and Unverified are what a done left out and what it did not exercise, kept on the card and told to the launcher.
Skipped string `json:"skipped,omitempty"`
Unverified string `json:"unverified,omitempty"`
// FollowUps is the backlog ids a spike's done filed, or none.
FollowUps string `json:"followups,omitempty"`
// contains filtered or unexported fields
}
FinishRequest is a session declaring its work over, or reporting on it.
type FixtureFault ¶
FixtureFault is one fixture that did not start, and why.
type FolderSwept ¶ added in v0.0.4
type FolderSwept struct {
Path string `json:"path"`
Card string `json:"card,omitempty"`
Bytes int64 `json:"bytes"`
Stashed string `json:"stashed,omitempty"`
}
FolderSwept is one folder a sweep removed.
type HelpRequest ¶
type HelpRequest struct {
// Agent is the wire name, the same one every hook uses.
Agent string `json:"agent"`
// TaskID is used when the session knows which card it belongs to.
TaskID string `json:"task_id,omitempty"`
// Ask is what it needs, in its own words. THE WHOLE POINT: without it this
// is `needs-input` with extra steps.
Ask string `json:"ask"`
// Blocked is whether it has actually stopped, or is carrying on and would
// like an answer when somebody has one.
//
// Two different things and the board treats them differently. A session
// that has stopped is worth interrupting somebody for. One that is still
// working and has a question is not.
//
// FALSE IS THE DEFAULT AND STOPPING IS THE DEFAULT, which reads backwards
// until you look at the flag: `atrium ask` stops, and `--continue` is how
// a session says it is carrying on. The field is named for the state and
// the flag is named for the decision, on purpose. A caller that omits this
// is saying nothing about what it is doing, and the safe reading of
// nothing is that the session is waiting.
Blocked bool `json:"blocked,omitempty"`
// Peer is the handle of another session to route this to, or empty to put
// it on the card for a human.
//
// A handle that does not resolve REFUSES rather than falling back to the
// board. Quietly asking a human instead would be atrium deciding who
// answers, and the card would then claim a peer was on the hook when
// nobody was. The refusal carries the handles that would have worked, the
// same way `tell` does.
Peer string `json:"peer,omitempty"`
// Verb and Stage make the ask a gate: the one verb waiting on the human (store.GateVerbs) and the stage it waits at.
Verb string `json:"verb,omitempty"`
Stage string `json:"stage,omitempty"`
}
HelpRequest is a session saying it cannot go on.
type HomeRemoved ¶
type HostFlag ¶ added in v0.0.5
type HostFlag struct {
PID int `json:"pid"`
Name string `json:"name"`
Shape string `json:"shape"`
CPUPct float64 `json:"cpu_pct"`
RSSBytes uint64 `json:"rss_bytes"`
IOPerSec int64 `json:"io_bytes_per_sec"`
Since time.Time `json:"since"`
Started time.Time `json:"started,omitempty"`
Owner string `json:"owner,omitempty"`
Whose string `json:"whose,omitempty"`
Limits []string `json:"limits,omitempty"`
Stop string `json:"stop"`
Say string `json:"say"`
}
type HostStatus ¶ added in v0.0.5
type HostStatus struct {
At time.Time `json:"at,omitempty"`
Procs int `json:"procs"`
HogPct int `json:"hog_pct"`
HogMinutes int `json:"hog_minutes"`
Flags []HostFlag `json:"flags"`
Limits []string `json:"limits,omitempty"`
Err string `json:"error,omitempty"`
Notice string `json:"notice,omitempty"`
}
type Limit ¶
Limit is one usage limit and when it resets.
Percentages rather than token counts, because that is what the payload carries and because "eighty percent of the week" is the number a human acts on. ResetsAt is optional: a limit with no reset time still says how close the account is.
type LimitEvent ¶
LimitEvent is one limit on the wire.
type LoginNeeded ¶
type LoginNeeded struct {
Reason string `json:"reason"`
Line string `json:"line,omitempty"`
Card string `json:"card,omitempty"`
Since time.Time `json:"since"`
}
LoginNeeded is the flag as the board and the hub read it.
type MarkedCard ¶
MarkedCard is one card a merge marked, and when it will be culled.
type MergeProof ¶
type MergeProof struct {
Into string `json:"into"`
Ref string `json:"ref"`
Tip string `json:"tip"`
Merged bool `json:"merged"`
}
MergeProof is one answer. Merged false is an answer, not an error: the ref is there and the area branch does not contain it yet.
type MergedResult ¶
type MergedResult struct {
Into string `json:"into"`
Marked []MarkedCard `json:"marked"`
Skipped []string `json:"skipped,omitempty"`
Off bool `json:"off,omitempty"`
// Exited is the work cards whose runner this merge asked to leave.
Exited []string `json:"exited,omitempty"`
}
MergedResult is what one `merged --into` did: `POST /v1/merged` answers it.
type Options ¶
type Options struct {
AgentAddr string // agent-facing listener, e.g. ":7777"
HumanAddr string // human-facing listener, e.g. ":7778"
DBPath string // sqlite file
LongPoll time.Duration // caps how long shutdown waits on parked agent requests
// Room is the hub-facing name this daemon is known by, when it is a room
// attached to a hub. It is exported to every launched session as
// ATRIUM_ROOM, so the session's HTTP control MCP registration can send
// X-Atrium-Room and the hub can scope its control calls to this room. Empty
// for a daemon with no hub, where there is no room to name.
Room string
// ShutdownToken guards POST /v1/shutdown. Empty means loopback only.
// Setting one says the endpoint is meant to be reachable remotely.
ShutdownToken string
// LocationFile is where this daemon records the address it is listening
// on. Empty means the machine's one true place for it, which is what a
// real daemon wants and what every caller looks in.
//
// It exists so a test can point somewhere else. Run writes this file on
// start and DELETES it on stop, so a test that starts a daemon and stops
// it was removing the address of whatever real daemon was running at the
// time. Nothing broke, because a caller that cannot find the file falls
// back to the default port and the daemon under test was on the default
// port anyway, which is exactly why it went unnoticed. On a non-default
// port it would have quietly unhooked every live session instead.
LocationFile string
// Passive means SERVE THE BOARD AND TOUCH NOTHING ELSE.
//
// For `atrium preview`, which opens a COPY of a database so a change to
// the board can be judged by using it. Everything in that copy is real:
// real fixtures, real shares, real cards. An ordinary start acts on all of
// them, so the first preview spawned the operator's runners and tried to
// take their zrok name off them, from a process that was supposed to be a
// window onto a copy.
//
// What it turns off is everything that reaches outside the process:
// fixtures, restoring lent shares, and sweeping dead ones. What stays on
// is the store, the API, the board, the event stream and the ability to
// attach to something you started HERE, because those are what is being
// looked at.
//
// Not a security boundary, and not a read-only mode. Somebody using a
// preview board can still launch a runner or shelve a card in the copy.
// The rule is narrower and it is about STARTUP: opening a database is not
// consent to act on what is in it.
Passive bool
// BoardDir serves the board from this directory instead of the embedded
// copy, so changing the page is a browser refresh rather than a restart
// that every supervised terminal on the machine pays for. Empty is the
// default and is the embed. See api.Server.BoardDir.
BoardDir string
// RoomDir is where a room keeps its certificate (`atrium room --dir`).
// It is only recorded in the location file, so a restart can pass it back.
RoomDir string
// Service is set when the SCM runs this room. Only recorded in the location file.
Service bool
// StartedBy is the `--started-by <kind>:<nonce>` a supervisor gave this
// process. KEPT IN MEMORY ONLY: never exported to the environment and never
// passed to anything this process spawns, so no child of a supervised room
// can claim to be one. `POST /v1/preflight` reports it. Empty when nothing
// supervised the start.
StartedBy string
// HostBuild is the build string a pty host this daemon starts reports in its probe, shown in /v1/preflight.
HostBuild string
}
Options configures a daemon.
type OutsideCard ¶
type Peer ¶
type Peer struct {
// Handle is what to address it as, which is the wire name.
Handle string `json:"handle"`
// Alias is the short name the operator gave it, accepted anywhere Handle
// is. Empty when none is set.
Alias string `json:"alias,omitempty"`
Title string `json:"title"`
Status string `json:"status"`
Runner string `json:"runner,omitempty"`
// Worktree is where it is working, which is usually the fastest way for a
// model to tell two sessions of the same repo apart.
Worktree string `json:"worktree,omitempty"`
// Why is what the operator said this card is for. The one field that says
// what a session is DOING rather than where it is.
Why string `json:"why,omitempty"`
// Parked is true when the card is idle with no process. A say to it is refused
// unless it asks to wake it. See park.go.
Parked bool `json:"parked,omitempty"`
// Waiting is how many messages are queued for it and undelivered. A peer
// with a pile already waiting is one to leave alone.
Waiting int `json:"waiting,omitempty"`
// What this card wants from a human, and how to read it. See fleet.go for
// the buckets and why they are in that order.
//
// Want is one of the Want constants. Note is the same thing in a sentence,
// which is what a list prints.
Want string `json:"want,omitempty"`
Note string `json:"note,omitempty"`
// Ask is the question a session asked, in its own words, and Blocked is
// whether it stopped to wait for the answer. Empty when nobody asked
// anything, which is not the same as a `Why` the operator typed.
Ask string `json:"ask,omitempty"`
Blocked bool `json:"blocked,omitempty"`
// AskPeer is who it asked, when the question was routed to another session
// rather than left on the card for a human. Empty otherwise.
//
// Here because the most useful thing in a list of peers is the one that is
// stopped waiting on somebody. A session that can answer it can see that
// from the list rather than having to be told.
AskPeer string `json:"ask_peer,omitempty"`
// Recap is what a finished session said it did, and empty on a card that
// finished without saying.
Recap string `json:"recap,omitempty"`
// Since is when this card started wanting what it wants, and Seconds is
// that as an age. Ordering within a bucket is oldest first.
Since time.Time `json:"since,omitempty"`
Seconds int64 `json:"seconds,omitempty"`
}
Peer is one session another session can address.
type PermissionRequest ¶
type PermissionRequest struct {
// Contract is the runner contract version the sender speaks. Absent means 1.
Contract int `json:"contract,omitempty"`
Runner string `json:"runner,omitempty"`
Agent string `json:"agent"`
TaskID string `json:"task_id,omitempty"`
Command string `json:"command"`
// NameSource is "dir" when Agent was made up from the directory, so
// Register will not match it to a finished card. Absent is a told name.
NameSource string `json:"name_source,omitempty"`
Tool string `json:"tool,omitempty"`
// PID is the runner's own process, not the hook's. It is what lets atrium
// tell a live session from a dead one by asking the operating system,
// which costs nothing, instead of asking the runner, which costs a turn.
PID int `json:"pid,omitempty"`
// Cwd is where the runner is working, used to fill in the card.
Cwd string `json:"cwd,omitempty"`
// Details is what the tool would actually do: the diff for an edit, the
// content for a write. The command line alone names the target without
// saying what happens to it, which is not enough to decide on.
Details string `json:"details,omitempty"`
// DedupKey identifies one attempt, so a retried request is recognized as
// the same question rather than asked again.
//
// The hook fails open when atrium is unreachable, and it also retries. A
// daemon that crashed between recording a decision and answering would
// otherwise ask the operator the same thing twice, and the second answer
// would be given against a situation that had already moved on. Empty is
// allowed and means "treat this as new".
//
// A key built by hashing the session, the tool and the command is stable
// across a retry AND across running the same command tomorrow, which is
// why a decided key is only replayable for a couple of minutes. Prefer
// ToolUseID: it does not have that problem.
DedupKey string `json:"dedup_key,omitempty"`
// ToolUseID is the runner's own id for this tool-use ATTEMPT.
//
// Claude Code's PreToolUse payload carries `tool_use_id`, and Codex has
// the same field. It is exactly what a dedup key wants and what a hash of
// the command can never be: the same across a retry of this attempt, and
// different for an identical command run later.
//
// When present it becomes the key and the replay window does not apply,
// because there is nothing to guard against. A hook that sends only a hash
// keeps the old behavior.
ToolUseID string `json:"tool_use_id,omitempty"`
}
PermissionRequest is the JSON shape POST'd by the claude PreToolUse hook.
type PermissionResponse ¶
type PermissionResponse struct {
Decision string `json:"decision"` // "approve" or "block"
Reason string `json:"reason,omitempty"`
// Command is present only when the human edited the command before
// approving it. A hook that does not understand this field ignores it and
// runs the original, so sending it is safe either way.
Command string `json:"command,omitempty"`
}
PermissionResponse is what the daemon returns to the hook.
type PtyHostReport ¶
type PtyHostReport struct {
Wrap WrapReport `json:"wrap"`
Ended int `json:"ended"`
Wanted int `json:"wanted"`
Reopened int `json:"reopened"`
OldPid int `json:"old_pid"`
NewPid int `json:"new_pid"`
}
PtyHostReport is what RestartPtyHost did.
type RelayLaunch ¶
type RelayLaunch = hublink.RelayLaunch
What the hublink package declares and the CLI reaches as daemon.X.
type RelayResult ¶
type RelayResult = hublink.RelayResult
type RemoteEvent ¶
type RemoteEvent = hublink.RemoteEvent
type RemotePeer ¶
type RemotePeer = hublink.RemotePeer
type RemoteTask ¶
type RemoteTask = hublink.RemoteTask
type RepliesView ¶
type RepliesView struct {
Source string `json:"source"`
Replies []Reply `json:"replies"`
// Prompts is what was said TO the card, from every source: typed at its
// terminal, sent from the desktop board or the phone, or typed by atrium for
// a peer. Oldest first, bounded like replies. Absent when atrium reads the
// screen, which cannot tell a prompt from output.
Prompts []Prompt `json:"prompts,omitempty"`
// More is true when replies or prompts older than the oldest in this page
// may exist. Never set for the screen.
More bool `json:"more"`
// NextBefore is the `before` of the next page, RFC3339Nano, set when More is
// true. Both lists are complete down to it, so a client passes it back as it
// is and never works out a cursor from the entries.
NextBefore string `json:"next_before,omitempty"`
}
RepliesView is the answer: where the text came from, and the replies oldest first.
type Reply ¶
type Reply struct {
At time.Time `json:"at"`
Text string `json:"text"`
Truncated bool `json:"truncated"`
// Edited is how many files the edit tool calls of this reply's turn named inside the
// card's worktree. From the transcript alone, no git: the numbers behind it come from
// one `?turn=<at>` call on /changes. Absent when there were none.
Edited int `json:"edited,omitempty"`
}
Reply is one reply as the page draws it.
type ResumeBusy ¶
type ResumeBusy struct {
// HolderID is the card already running this conversation. The board
// attaches to it directly rather than asking the operator to find it.
HolderID string `json:"holder_id"`
// HolderTitle is what that card is called. A display title, so two cards
// can plausibly wear it, which is why the directory is here too.
HolderTitle string `json:"holder_title"`
// Worktree tells them apart when the title does not.
Worktree string `json:"worktree"`
// Resume is the conversation id. The operator cannot see it anywhere else
// and it is the thing they would search for.
Resume string `json:"resume"`
}
ResumeBusy is the refusal above, as something a client can act on.
It used to be a `fmt.Errorf` whose text named both ways out and offered neither: "braid its transcript into a thread neither of them wrote. attach to that one, or start a fresh session here instead", under a single `ok` button. Three figures of speech in nine words, and the only actionable sentence in the dialog was the tail of the hardest one. The operator then had to work out which remedy he wanted and go and perform it somewhere else.
Both remedies are things the daemon already knows how to do, and it knows WHICH card is holding the conversation because it just found it. So it says so in fields rather than in prose, and the board draws two buttons.
The message stays readable on its own, because a CLI caller and an old board both only get `Error()`.
func (*ResumeBusy) Error ¶
func (e *ResumeBusy) Error() string
Error says what happened and what it means, and leaves what to press to the buttons. No metaphor: a modal that appears when somebody is blocked is a different audience from a comment explaining why the guard exists.
func (*ResumeBusy) ResumeConflict ¶
func (e *ResumeBusy) ResumeConflict() map[string]any
ResumeConflict is what the API sends when it recognises this refusal.
A method rather than a type the API imports, because `internal/daemon` already imports `internal/api` and the reverse would be a cycle. The API tests for the METHOD, so the daemon can grow a second actionable refusal without the API learning its name.
type SessionEvent ¶
type SessionEvent struct {
// Contract is the runner contract version the sender speaks. Absent means 1.
Contract int `json:"contract,omitempty"`
// Features are the contract calls the adapter says it makes: session, activity, permission, stop, finish.
Features []string `json:"features,omitempty"`
Agent string `json:"agent"`
// Event is "start" or "end".
Event string `json:"event"`
Runner string `json:"runner,omitempty"`
Cwd string `json:"cwd,omitempty"`
PID int `json:"pid,omitempty"`
// TaskID binds a launched runner to the card that launched it.
TaskID string `json:"task_id,omitempty"`
// Resume is the runner's own session id, so a card can be picked back up.
Resume string `json:"resume,omitempty"`
// Resumable is whether there is a conversation behind that id yet.
//
// A pointer, so "the hook did not say" is distinguishable from "the hook
// said no". An older hook binary sends neither and is trusted, which is
// what it was before this existed.
Resumable *bool `json:"resumable,omitempty"`
// Source is the harness's own word for why the session started, such as
// startup, resume or clear. Recorded, not interpreted.
Source string `json:"source,omitempty"`
// Reason is the harness's word for why a session ENDED. `clear` and
// `resume` both mean another session is starting immediately in the same
// place, so the card should not die and come back a second later.
//
// The hook already declines to post those, and this is checked again here
// anyway: the daemon cannot assume which version of the hook binary is
// installed, and an old one posting an end for a clear would flicker a
// card out of the column somebody was reading.
Reason string `json:"reason,omitempty"`
// Trigger is why a compaction happened: `auto` or `manual`. Recorded and
// not acted on. The interesting part is that it happened at all.
Trigger string `json:"trigger,omitempty"`
// Title and Why are supplied when a session joins by hand, since that is
// the one moment someone can say what the session is for.
Title string `json:"title,omitempty"`
Why string `json:"why,omitempty"`
// NameSource is "dir" when the hook made Agent up from its directory. See
// store.Observed.NameSource.
NameSource string `json:"name_source,omitempty"`
}
SessionEvent is what a session hook posts.
type StampReply ¶
type StampReply struct {
AtSHA string `json:"at_sha"`
Dirty bool `json:"dirty"`
// Branch is the branch the worktree is on, "HEAD" when it is detached.
Branch string `json:"branch"`
// LogPath is where the log was kept on this room, "" when there was none.
LogPath string `json:"log_path,omitempty"`
}
StampReply is what the room read.
type Subagent ¶
type Subagent struct {
// ID pairs a stop with its start. Never shown.
ID string `json:"id"`
// Type is what the runner calls it: `explore`, `general-purpose`, the name
// of a custom agent. This is the part worth reading.
Type string `json:"type,omitempty"`
// Since is when it started, so a subagent that has been going for four
// minutes is distinguishable from one that just began.
Since time.Time `json:"since"`
// Seconds is Since as an age, filled in when the activity is served.
Seconds int64 `json:"seconds"`
}
Activity is one runner's current state. Zero value means nothing is known. Subagent is one agent running under a session.
Held in memory with the rest of the activity and never written down, for the same reason: it is a fact about a process that is running right now, and it would be a lie the moment the daemon restarted.
type Telemetry ¶
type Telemetry struct {
// Pct is context used as a percentage of the window, always filled in.
// Derived from Used and Window when both are given, since a caller that
// sends all three can contradict itself and the pair is the better source.
Pct int `json:"pct"`
// Used and Window are the tokens behind it, when the caller knows them.
// Shown in the tooltip, so "92%" can be read as a size rather than only as
// a fraction.
Used int `json:"used,omitempty"`
Window int `json:"window,omitempty"`
// Model is what the session is running, as the harness displays it. Worth
// having beside a percentage: the same percentage is a different amount of
// remaining room on a different window.
Model string `json:"model,omitempty"`
// FiveHour and Weekly are the account's rolling limits. Absent when the
// caller does not report them, which is the normal case for a plan that
// has none.
FiveHour *Limit `json:"five_hour,omitempty"`
Weekly *Limit `json:"weekly,omitempty"`
// Since is when this figure arrived, so the board can age it and so a
// stale one can be dropped.
Since time.Time `json:"since"`
// Seconds is Since as an age, filled in when the telemetry is served.
Seconds int64 `json:"seconds"`
}
Telemetry is one session's context and limit picture.
type TelemetryEvent ¶
type TelemetryEvent struct {
// SessionID is the harness's own id for the conversation, which atrium
// already stores as a card's resume id. The primary key, because it is the
// one identifier a statusline definitely has.
SessionID string `json:"session_id,omitempty"`
// TaskID is the card outright, for a caller that was told which one it is.
// Beats every other key when present.
TaskID string `json:"task_id,omitempty"`
// Agent is the wire name, the fallback every other hook uses.
Agent string `json:"agent,omitempty"`
// ContextUsed and ContextWindow are tokens. Preferred over ContextPct.
ContextUsed int `json:"context_used,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
// ContextPct is for a caller that only knows the fraction.
ContextPct int `json:"context_pct,omitempty"`
Model string `json:"model,omitempty"`
// FiveHour and Weekly carry a percentage and an RFC3339 reset time. A
// reset time that will not parse is dropped rather than refused: the
// percentage is the part that decides anything.
FiveHour *LimitEvent `json:"five_hour,omitempty"`
Weekly *LimitEvent `json:"weekly,omitempty"`
}
TelemetryEvent is what a statusline posts to /telemetry.
Deliberately not Claude Code's statusline payload passed through. That payload is the harness's to change, it carries a great deal atrium has no business holding, and a contract shaped like somebody else's internal JSON is one that breaks on their release schedule. The caller extracts, atrium receives named fields.
type UsageView ¶
type UsageView struct {
Totals *store.UsageTotals `json:"totals"`
ByCause map[string]*store.UsageTotals `json:"by_cause"`
// ContextNow is the context of the last main reply in the transcript,
// read now. Zero when there is none.
ContextNow int64 `json:"context_now"`
Model string `json:"model,omitempty"`
Rows []*store.SessionUsage `json:"rows"`
}
UsageView is what a card's details show.
type WrapReport ¶
type WrapReport = cycle.WrapReport
What the cycle package declares and the CLI reaches as daemon.X.
Source Files
¶
- a2a.go
- actions.go
- activity.go
- activity_cycle.go
- activity_iface.go
- address.go
- archiveworkers.go
- artifacts.go
- attach.go
- autocompact.go
- autocontext.go
- capabilities.go
- cardlabel.go
- cardmem.go
- carryover.go
- chat.go
- clone.go
- closehub.go
- closestash.go
- contextlog.go
- contextsize.go
- contract.go
- controlmcp.go
- cull.go
- cullhelp.go
- cycle_forward.go
- daemon.go
- dictate.go
- diskwatch.go
- dispatch.go
- drafts.go
- drain.go
- endedfolders.go
- endonce.go
- escalate.go
- exitonreport.go
- finish.go
- firstrun.go
- fixtures.go
- fleet.go
- forceclear.go
- forcesay.go
- fyi.go
- hand.go
- help.go
- hoisted.go
- home_forward.go
- homedisk.go
- hooks.go
- hostterm.go
- hostwatch.go
- hublink_forward.go
- hubworktree.go
- idlepark.go
- idletick.go
- incomingsweep.go
- inputlag.go
- interview.go
- item.go
- item_hub.go
- item_pool.go
- item_stuck.go
- keep.go
- keepalive_args.go
- keepalive_env.go
- killtree_other.go
- landed.go
- launch.go
- launchersay.go
- launchstuck.go
- lean.go
- lean_agents.go
- learnings.go
- ledger.go
- letthrough.go
- localserve.go
- loginneeded.go
- loginstatus.go
- logline.go
- looksidle.go
- mergedcull.go
- mergeproof.go
- messages.go
- modelswitch.go
- move.go
- movegit.go
- movein.go
- moveroutes.go
- need.go
- nosession.go
- opencodeproc_unix.go
- opencodereader.go
- orphans.go
- outputat.go
- owed.go
- park.go
- peers.go
- pendinginject.go
- permwait.go
- preflight.go
- prepare.go
- prepare_other.go
- priority_other.go
- pulls_routes.go
- reaper.go
- reclaim.go
- recognise.go
- record.go
- registry.go
- reopen.go
- replies.go
- repliesall.go
- reportto.go
- restart_session.go
- restartpty.go
- resumeclaim.go
- room_events.go
- roomconf_forward.go
- roomguess.go
- roomsize.go
- roomstats.go
- runnersetup.go
- runnerupdate.go
- saylog.go
- saywhen.go
- scratch.go
- seen.go
- session.go
- settle.go
- settling.go
- setupfile.go
- shell.go
- shelve.go
- shutdown.go
- sources.go
- stopkeep.go
- supervisor.go
- sweep.go
- task_capture.go
- task_launch.go
- telemetry.go
- term.go
- throwaway.go
- toolchain.go
- tooldiscover.go
- toollocations.go
- transcriptreader.go
- turncost.go
- typedline.go
- typedproof.go
- unexpectedexit.go
- usage.go
- usagebackfill.go
- vacuum.go
- visible.go
- whichdb.go
- workerpolicy.go
- worktreegone.go
- worktrees.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dictate keeps one whisper.cpp `whisper-server` warm on this room and asks it to turn a spoken clip into text.
|
Package dictate keeps one whisper.cpp `whisper-server` warm on this room and asks it to turn a spoken clip into text. |
|
Package shared holds what the daemon's feature packages need from the room without importing it.
|
Package shared holds what the daemon's feature packages need from the room without importing it. |