Documentation
¶
Overview ¶
Package server is `actp serve`: it runs ACP agents and serves them to actp bridges.
Index ¶
- Constants
- type AgentState
- type Link
- type LinkInfo
- type Options
- type PublicCheck
- type Server
- func (s *Server) Agents() []AgentState
- func (s *Server) Close(grace time.Duration)
- func (s *Server) Config() *config.Server
- func (s *Server) EndLink(id string) bool
- func (s *Server) GetHealth(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetInfo(w http.ResponseWriter, r *http.Request)
- func (s *Server) Handler() http.Handler
- func (s *Server) LastPublicCheck() (PublicCheck, bool)
- func (s *Server) Links() []LinkInfo
- func (s *Server) ListAgents(w http.ResponseWriter, r *http.Request)
- func (s *Server) OpenLink(w http.ResponseWriter, r *http.Request, agentID api.AgentId, ...)
- func (s *Server) Probe(agent *config.Agent) (status, detail string)
- func (s *Server) PublicURL() string
- func (s *Server) Reload(cfg *config.Server)
- func (s *Server) SetPublicCheck(c PublicCheck)
- func (s *Server) SetPublicURL(u string)
Constants ¶
const ( StateAttached = "attached" StateDetached = "detached" StateUnattended = "unattended" StateEnded = "ended" )
Link states (design 3.1).
const ProbeTimeout = 10 * time.Second
ProbeTimeout bounds how long an agent may take to answer initialize.
const TombstoneFor = 10 * time.Minute
TombstoneFor is how long an ended link keeps output its client has not received.
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 ¶
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 (*Server) Agents ¶
func (s *Server) Agents() []AgentState
Agents lists every configured agent with its last known status.
func (*Server) Close ¶
Close ends every link, settling its agent, and waits up to grace for running turns.
func (*Server) LastPublicCheck ¶
func (s *Server) LastPublicCheck() (PublicCheck, bool)
LastPublicCheck returns the last public URL check, if any.
func (*Server) ListAgents ¶
func (s *Server) ListAgents(w http.ResponseWriter, r *http.Request)
func (*Server) OpenLink ¶
func (s *Server) OpenLink(w http.ResponseWriter, r *http.Request, agentID api.AgentId, params api.OpenLinkParams)
func (*Server) Probe ¶
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) Reload ¶
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 ¶
SetPublicURL records the tunnel's public URL for /api/v1/info.