server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server is `actp serve`: it runs ACP agents and serves them to actp bridges.

Index

Constants

View Source
const (
	StateAttached   = "attached"
	StateDetached   = "detached"
	StateUnattended = "unattended"
	StateEnded      = "ended"
)

Link states (design 3.1).

View Source
const ProbeTimeout = 10 * time.Second

ProbeTimeout bounds how long an agent may take to answer initialize.

View Source
const TombstoneFor = 10 * time.Minute

TombstoneFor is how long an ended link keeps output its client has not received.

View Source
const WorkspaceScheme = "actp://"

WorkspaceScheme is the cwd form that names a workspace: actp://<workspace>/<sub/path>.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentState

type AgentState struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Status   string `json:"status"`
	AuthHint string `json:"authHint,omitempty"`
	Error    string `json:"error,omitempty"`
}

AgentState is an agent's status for the dashboard and the tray.

type Link struct {
	// contains filtered or unexported fields
}

Link is one ACP connection to one agent process (design 1, wire 3).

type LinkInfo

type LinkInfo struct {
	ID         string
	Agent      string
	Token      string
	ClientName string
	State      string
	Since      time.Time
	Running    bool
}

LinkInfo describes a link for the tray and the CLI.

type Options

type Options struct {
	Version string
	// BaseEnv is the environment agents start from. Nil means the login shell's
	// environment when shell_env is on (the default), else os.Environ().
	BaseEnv []string
	Logger  *slog.Logger
	Wire    wire.Options
	// Tick is how often links check their timers (1 s).
	Tick time.Duration
	// ProbeOnStart runs an initialize probe against every agent at start.
	ProbeOnStart bool
	// ReadOnly is for tools like `actp doctor`: no crash cleanup, no audit log.
	ReadOnly bool
	// ModeResetTimeout bounds how long an agent may take to answer actp's
	// switch of a session's starting mode (10 s).
	ModeResetTimeout time.Duration
	// HeldLoadTimeout bounds how long a session/load or session/resume may
	// hold the session's next messages (60 s); MaxHeldMessages and MaxHeldBytes
	// bound that queue (256 messages, 8 MB).
	HeldLoadTimeout time.Duration
	MaxHeldMessages int
	MaxHeldBytes    int
}

Options are knobs mostly used by tests.

type PublicCheck

type PublicCheck struct {
	OK     bool      `json:"ok"`
	Detail string    `json:"detail,omitempty"`
	At     time.Time `json:"at"`
}

PublicCheck is the result of the last check of the public URL from outside.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds configuration, links and agent status.

func New

func New(cfg *config.Server, opts Options) (*Server, error)

New builds a server for a validated config.

func (*Server) Agents

func (s *Server) Agents() []AgentState

Agents lists every configured agent with its last known status.

func (*Server) Close

func (s *Server) Close(grace time.Duration)

Close ends every link, settling its agent, and waits up to grace for running turns.

func (*Server) Config

func (s *Server) Config() *config.Server

Config is the configuration the server runs with now.

func (s *Server) EndLink(id string) bool

EndLink ends a link on an operator's request.

func (*Server) GetHealth

func (s *Server) GetHealth(w http.ResponseWriter, r *http.Request)

func (*Server) GetInfo

func (s *Server) GetInfo(w http.ResponseWriter, r *http.Request)

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler serves the HTTP API.

func (*Server) LastPublicCheck

func (s *Server) LastPublicCheck() (PublicCheck, bool)

LastPublicCheck returns the last public URL check, if any.

func (s *Server) Links() []LinkInfo

Links lists the open links.

func (*Server) ListAgents

func (s *Server) ListAgents(w http.ResponseWriter, r *http.Request)
func (s *Server) OpenLink(w http.ResponseWriter, r *http.Request, agentID api.AgentId, params api.OpenLinkParams)

func (*Server) Probe

func (s *Server) Probe(agent *config.Agent) (status, detail string)

Probe starts an agent, runs initialize without a session, and records the result for /api/v1/agents (design 3.4). It returns the recorded status.

func (*Server) PublicURL

func (s *Server) PublicURL() string

PublicURL is the tunnel's public URL, if any.

func (*Server) Reload

func (s *Server) Reload(cfg *config.Server)

Reload switches to a new configuration. New links and new requests use it; open links keep running with the settings they started with. A revoked token cannot open or resume links any more.

func (*Server) SetPublicCheck

func (s *Server) SetPublicCheck(c PublicCheck)

SetPublicCheck records whether the public URL answered.

func (*Server) SetPublicURL

func (s *Server) SetPublicURL(u string)

SetPublicURL records the tunnel's public URL for /api/v1/info.

Jump to

Keyboard shortcuts

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