Documentation
¶
Index ¶
- type Registry
- func (r *Registry) AgentsDone() bool
- func (r *Registry) AllTeleportedAway() bool
- func (r *Registry) Attach(c sessionsdomain.Client)
- func (r *Registry) Deliver(key sessionsdomain.ThreadKey, frame []byte)
- func (r *Registry) Detach(c sessionsdomain.Client)
- func (r *Registry) Handle(c sessionsdomain.Client, frame []byte)
- func (r *Registry) Idle() (time.Time, bool)
- func (r *Registry) Quiesce(ctx context.Context, key sessionsdomain.ThreadKey) (json.RawMessage, error)
- func (r *Registry) Request(ctx context.Context, frame []byte, replyType string) ([]byte, error)
- func (r *Registry) RouteBrowser(relay sessionsdomain.BrowserRelay)
- func (r *Registry) Run(ctx context.Context)
- func (r *Registry) TeleportedAway(key sessionsdomain.ThreadKey)
- func (r *Registry) TeleportedHere(key sessionsdomain.ThreadKey)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the daemon's thread registry. It launches one worker per thread, relays client frames to worker stdin and worker lines to the thread's clients, and stops idle workers. Two answers race per thread and the first wins each: the resume of a suspended run's interrupts (an incomplete resume is refused with RUN_ERROR) and the approval_response of a panel tool_request. A run a crashed worker left open ends with RUN_ERROR, and worker browser_command frames route to the connected browser extension. Run state changes broadcast a thread_activity frame to every attached client.
func NewRegistry ¶
func NewRegistry(launch sessionsdomain.LaunchWorker, idle time.Duration) *Registry
NewRegistry builds a registry that launches workers with launch and stops the ones nobody follows once they sat idle for idle.
func (*Registry) AgentsDone ¶ added in v0.239.0
AgentsDone reports whether the last run of every thread this registry ran finished without waiting on the user, and every session that teleported here and stayed had such a run. A run still open, suspended on an interrupt or ended by an error is not done, and neither is no run at all, unless every session that teleported here left again.
func (*Registry) AllTeleportedAway ¶ added in v0.239.0
AllTeleportedAway reports whether a session teleported away from this daemon and every one that teleported here since left again, so it hosts none.
ponytail: a session started on this daemon without a teleport is not counted. A pod has none. Count the registry's own threads if a daemon ever mixes both.
func (*Registry) Attach ¶ added in v0.236.0
func (r *Registry) Attach(c sessionsdomain.Client)
Attach registers a connected client so thread_activity frames reach it even before it follows any thread, and answers with what streams right now - a client that attaches mid-run learns nothing else until the next run state change. Detach drops it again.
func (*Registry) Deliver ¶ added in v0.239.0
func (r *Registry) Deliver(key sessionsdomain.ThreadKey, frame []byte)
Deliver sends one frame to every client following the thread.
func (*Registry) Detach ¶
func (r *Registry) Detach(c sessionsdomain.Client)
Detach drops a disconnected client. Its thread keeps running an open turn and is stopped once idle.
func (*Registry) Handle ¶
func (r *Registry) Handle(c sessionsdomain.Client, frame []byte)
Handle routes one client frame. new_session and resume_conversation make the client follow that thread, panel requests run on a worker in their project dir, and approval_response answers the approval it names once.
func (*Registry) Idle ¶ added in v0.239.0
Idle reports whether the registry has no thread and no client, and when it last had either.
func (*Registry) Quiesce ¶ added in v0.239.0
func (r *Registry) Quiesce(ctx context.Context, key sessionsdomain.ThreadKey) (json.RawMessage, error)
Quiesce brings a thread to rest for a teleport: it interrupts an open run, waits for it to end, stops the worker so its storage is flushed, and returns the interrupts the run was suspended on, as the worker wrote them. The thread and its clients stay, so a later frame relaunches a worker.
func (*Registry) Request ¶ added in v0.239.0
Request sends one panel frame on a worker in the frame's project dir and returns the reply of replyType. A RUN_ERROR in its place is the error the worker or the registry raised.
func (*Registry) RouteBrowser ¶
func (r *Registry) RouteBrowser(relay sessionsdomain.BrowserRelay)
RouteBrowser wires the relay worker browser_command frames take to the extension connection. Call it once before any worker launches, which is what lets pump read the field without the registry lock.
func (*Registry) Run ¶
Run stops idle workers until ctx ends, then stops every worker and waits for them to exit.
func (*Registry) TeleportedAway ¶ added in v0.239.0
func (r *Registry) TeleportedAway(key sessionsdomain.ThreadKey)
TeleportedAway records that a thread's session now lives in another workspace. Its last run here, interrupted or never started, no longer keeps AgentsDone false.
func (*Registry) TeleportedHere ¶ added in v0.239.0
func (r *Registry) TeleportedHere(key sessionsdomain.ThreadKey)
TeleportedHere records that a thread's session arrived from another workspace, so this daemon hosts it until it teleports away again.