server

package
v0.60.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentHealthMonitor added in v0.30.0

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

AgentHealthMonitor periodically marks stale agents as offline.

func NewAgentHealthMonitor added in v0.30.0

func NewAgentHealthMonitor(database *db.DB) *AgentHealthMonitor

func (*AgentHealthMonitor) Run added in v0.30.0

func (m *AgentHealthMonitor) Run(ctx context.Context)

Run blocks until ctx is cancelled.

type ExecutorsClient added in v0.50.4

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

ExecutorsClient talks to codex-exec-gateway's user-management API on behalf of a session-authenticated agentserver user. Every request carries:

  • X-Internal-Secret: agentserver's INTERNAL_API_SECRET (matches the RequireAgentserverSecret middleware on the gateway side)
  • X-User-Id: the calling user's ID (gateway uses this for its own ownership ACL on executors)

func NewExecutorsClient added in v0.50.4

func NewExecutorsClient(baseURL, secret string) *ExecutorsClient

func (*ExecutorsClient) Bind added in v0.50.4

func (c *ExecutorsClient) Bind(ctx context.Context, userID, workspaceID, exeID, name, description string, isDefault bool) error

Bind attaches an existing executor to a workspace under the caller-supplied name (workspace-unique). description is optional.

func (*ExecutorsClient) List added in v0.50.4

func (c *ExecutorsClient) List(ctx context.Context, userID, workspaceID string) ([]ListedExecutor, error)

List returns all executors bound to the workspace.

func (*ExecutorsClient) Register added in v0.50.4

Register creates a new executor owned by userID and returns the raw registration token (one-time).

func (*ExecutorsClient) Unbind added in v0.50.4

func (c *ExecutorsClient) Unbind(ctx context.Context, userID, workspaceID, exeID string) error

Unbind removes an executor from a workspace.

func (*ExecutorsClient) Unregister added in v0.54.2

func (c *ExecutorsClient) Unregister(ctx context.Context, userID, exeID string) error

Unregister deletes an executor row (and any of its bindings via CASCADE) from the gateway store. Used by the agentserver Register handler to clean up after a failed Bind so we don't leak orphan executors. Idempotent: 404 is treated as success.

type IMInboundMessage added in v0.40.0

type IMInboundMessage struct {
	ChatJID    string `json:"chat_jid"`
	SenderName string `json:"sender_name"`
	Content    string `json:"content"`
	Provider   string `json:"provider"`
	ChannelID  string `json:"channel_id"`
}

IMInboundMessage represents an inbound message from an IM channel.

type LeakWorker added in v0.47.0

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

LeakWorker is a background goroutine that cleans up stale active turns and responders.

func NewLeakWorker added in v0.47.0

func NewLeakWorker(s *Server, cfg LeakWorkerConfig) *LeakWorker

NewLeakWorker creates a new LeakWorker with defaults applied to zero values.

func (*LeakWorker) Run added in v0.47.0

func (l *LeakWorker) Run(ctx context.Context)

Run starts the ticker loop until ctx is cancelled.

func (*LeakWorker) RunOnce added in v0.47.0

func (l *LeakWorker) RunOnce(ctx context.Context)

RunOnce runs both cleanup sweeps once. Exposed for testing.

type LeakWorkerConfig added in v0.47.0

type LeakWorkerConfig struct {
	StaleTurnAfter time.Duration // default 5m
	ResponderTTL   time.Duration // default 90s
	Period         time.Duration // default 1m
}

LeakWorkerConfig holds configuration for the leak worker.

type ListedExecutor added in v0.50.4

type ListedExecutor struct {
	ExeID       string     `json:"exe_id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	IsDefault   bool       `json:"is_default"`
	LastSeenAt  *time.Time `json:"last_seen_at,omitempty"`
}

ListedExecutor matches codex-exec-gateway's GET /api/codex-exec/workspaces/{wid}/executors element shape. Per v0.54.0, surfaced fields are binding-level (name + description) from workspace_executors, not the executor row.

type RegisterExecutorRequest added in v0.50.4

type RegisterExecutorRequest struct {
	DisplayName string `json:"display_name,omitempty"`
}

RegisterExecutorRequest matches codex-exec-gateway's POST /api/codex-exec/register body. Per v0.54.0, executors no longer carry a default_cwd; that field was useless to the LLM and confusing in the UI.

type RegisterExecutorResponse added in v0.50.4

type RegisterExecutorResponse struct {
	ExeID             string `json:"exe_id"`
	RegistrationToken string `json:"registration_token"`
}

RegisterExecutorResponse matches codex-exec-gateway's response (raw token is returned ONCE — agentserver forwards it to the web UI for one-time display, never stores it).

type ResourceDefaults added in v0.7.0

type ResourceDefaults struct {
	MaxWorkspacesPerUser     int
	MaxSandboxesPerWorkspace int
	MaxWorkspaceDriveSize    int64 // bytes
	MaxSandboxCPU            int   // millicores
	MaxSandboxMemory         int64 // bytes
	MaxIdleTimeout           int   // seconds
	WsMaxTotalCPU            int   // millicores
	WsMaxTotalMemory         int64 // bytes
	WsMaxIdleTimeout         int   // seconds
}

ResourceDefaults holds all resolved system-wide defaults.

type Server

type Server struct {
	Auth                      *auth.Auth
	OIDC                      *auth.OIDCManager
	DB                        *db.DB
	Sandboxes                 *sbxstore.Store
	ProcessManager            process.Manager
	DriveManager              storage.DriveManager
	NamespaceManager          *namespace.Manager
	TunnelRegistry            *tunnel.Registry
	StaticFS                  fs.FS
	BaseDomains               []string // e.g. ["agentserver.dev", "agent.cs.ac.cn"] (first is primary)
	OpencodeSubdomainPrefix   string   // e.g. "code" — subdomain: code-{id}.{baseDomain}
	OpenclawSubdomainPrefix   string   // e.g. "claw" — subdomain: claw-{id}.{baseDomain}
	ClaudeCodeSubdomainPrefix string   // e.g. "claude" — subdomain: claude-{id}.{baseDomain}
	JupyterSubdomainPrefix    string   // e.g. "jupyter" — subdomain: jupyter-{id}.{baseDomain}
	PasswordAuthEnabled       bool     // when false, /api/auth/login and /api/auth/register are not registered
	LLMProxyURL               string   // base URL for the llmproxy service (e.g. "http://agentserver-llmproxy:8081")

	// IMBridgeURL is the base URL of the standalone imbridge service
	// (e.g. "http://agentserver-imbridge:8083"). When set, IM API routes
	// are reverse-proxied to the imbridge service.
	IMBridgeURL string

	// ModelServer OAuth
	ModelserverOAuthClientID      string
	ModelserverOAuthClientSecret  string
	ModelserverOAuthAuthURL       string
	ModelserverOAuthTokenURL      string
	ModelserverOAuthIntrospectURL string
	ModelserverOAuthRedirectURI   string
	ModelserverProxyURL           string
	DatabaseURL                   string // PostgreSQL connection URL (needed for Matrix E2EE crypto DB)

	// Hydra OAuth2 (for agent Device Flow)
	HydraClient    *auth.HydraClient
	HydraPublicURL string // internal URL for reverse proxy (e.g. "http://hydra-public:4444")

	// BridgeHandler provides CCR V2-compatible bridge API for agent sessions.
	BridgeHandler *bridge.Handler

	// CCBrokerURL is the base URL of the cc-broker service for stateless
	// Claude Code sessions (e.g. "http://cc-broker:8090").
	CCBrokerURL string

	// ExecutorRegistryURL is the base URL of the executor-registry service
	// (e.g. "http://executor-registry:8091"). Used by the /control agents command.
	ExecutorRegistryURL string

	// Credential proxy
	EncryptionKey      []byte // AES-256 key for credential_bindings auth_blob
	CredproxyPublicURL string // URL sandboxes use to reach credentialproxy

	// Codex exec gateway
	ExecutorsClient            *ExecutorsClient
	CodexExecGatewayPublicHost string // e.g. "codex-exec.example.com" — used to compose connect commands

	// OperationsRetention is the TTL for rows in the operations table.
	// 0 disables the background retention loop. Configurable via
	// AGENTSERVER_OPERATIONS_RETENTION_DAYS (default 90).
	OperationsRetention time.Duration
	// contains filtered or unexported fields
}

func New

func New(a *auth.Auth, oidcMgr *auth.OIDCManager, database *db.DB, sandboxStore *sbxstore.Store, processManager process.Manager, driveManager storage.DriveManager, nsMgr *namespace.Manager, tunnelReg *tunnel.Registry, staticFS fs.FS, passwordAuthEnabled bool) *Server

func (*Server) GetEffectiveIdleTimeout added in v0.7.0

func (s *Server) GetEffectiveIdleTimeout() time.Duration

GetEffectiveIdleTimeout is the exported version for use by cmd/serve.go.

func (*Server) Router

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

func (*Server) StartRetentionLoop added in v0.57.0

func (s *Server) StartRetentionLoop(ctx context.Context, ttl time.Duration, every time.Duration)

StartRetentionLoop is the exported entry point for the server's main lifecycle to launch the retention loop in a goroutine.

type WorkspaceDefaults added in v0.9.0

type WorkspaceDefaults struct {
	MaxSandboxes     int
	MaxSandboxCPU    int   // millicores
	MaxSandboxMemory int64 // bytes
	MaxIdleTimeout   int   // seconds
	MaxTotalCPU      int   // millicores
	MaxTotalMemory   int64 // bytes
	MaxDriveSize     int64 // bytes
}

WorkspaceDefaults holds workspace-level resolved defaults (system defaults <- workspace_quotas override).

Jump to

Keyboard shortcuts

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