httpapi

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInfo

type AgentInfo struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
}

AgentInfo describes one supported agent entry returned by /v1/agents.

type AgentModelsFactory

type AgentModelsFactory func(ctx context.Context, agentID string) ([]agents.ModelOption, error)

AgentModelsFactory resolves selectable model options for one agent.

type Config

type Config struct {
	AuthToken          string
	DataDir            string
	Agents             []AgentInfo
	AllowedAgentIDs    []string
	AllowedRoots       []string
	Store              ThreadStore
	TurnController     *runtime.TurnController
	Agent              agents.Streamer
	TurnAgentFactory   TurnAgentFactory
	AgentModelsFactory AgentModelsFactory
	AgentIdleTTL       time.Duration
	Logger             *observability.Logger
	ContextRecentTurns int
	ContextMaxChars    int
	CompactMaxChars    int
	PermissionTimeout  time.Duration
	// FrontendHandler, if non-nil, is served for any request that does not
	// match /healthz or /v1/*. Intended for the embedded web UI.
	FrontendHandler http.Handler
}

Config controls HTTP API behavior.

type Server

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

Server serves the HTTP API.

func New

func New(cfg Config) *Server

New creates a new API server.

func (*Server) Close

func (s *Server) Close() error

Close stops background janitor and closes all cached thread agents.

func (*Server) ServeHTTP

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

ServeHTTP handles all HTTP requests.

type ThreadStore

type ThreadStore interface {
	UpsertClient(ctx context.Context, clientID string) error
	CreateThread(ctx context.Context, params storage.CreateThreadParams) (storage.Thread, error)
	GetThread(ctx context.Context, threadID string) (storage.Thread, error)
	DeleteThread(ctx context.Context, threadID string) error
	UpdateThreadTitle(ctx context.Context, threadID, title string) error
	UpdateThreadSummary(ctx context.Context, threadID, summary string) error
	UpdateThreadAgentOptions(ctx context.Context, threadID, agentOptionsJSON string) error
	UpsertAgentConfigCatalog(ctx context.Context, params storage.UpsertAgentConfigCatalogParams) error
	GetAgentConfigCatalog(ctx context.Context, agentID, modelID string) (storage.AgentConfigCatalog, error)
	ListAgentConfigCatalogsByAgent(ctx context.Context, agentID string) ([]storage.AgentConfigCatalog, error)
	GetAgentSlashCommands(ctx context.Context, agentID string) (storage.AgentSlashCommands, error)
	UpsertAgentSlashCommands(ctx context.Context, params storage.UpsertAgentSlashCommandsParams) error
	GetSessionTranscriptCache(ctx context.Context, agentID, cwd, sessionID string) (storage.SessionTranscriptCache, error)
	UpsertSessionTranscriptCache(ctx context.Context, params storage.UpsertSessionTranscriptCacheParams) error
	GetSessionConfigCache(ctx context.Context, agentID, cwd, sessionID string) (storage.SessionConfigCache, error)
	UpsertSessionConfigCache(ctx context.Context, params storage.UpsertSessionConfigCacheParams) error
	ListThreads(ctx context.Context) ([]storage.Thread, error)
	CreateTurn(ctx context.Context, params storage.CreateTurnParams) (storage.Turn, error)
	CreateTurnAttachments(ctx context.Context, params []storage.CreateTurnAttachmentParams) error
	GetTurnAttachment(ctx context.Context, attachmentID string) (storage.TurnAttachment, error)
	GetTurn(ctx context.Context, turnID string) (storage.Turn, error)
	ListTurnsByThread(ctx context.Context, threadID string) ([]storage.Turn, error)
	AppendEvent(ctx context.Context, turnID, eventType, dataJSON string) (storage.Event, error)
	ListEventsByTurn(ctx context.Context, turnID string) ([]storage.Event, error)
	FinalizeTurn(ctx context.Context, params storage.FinalizeTurnParams) error
	ListRecentDirectories(ctx context.Context, clientID string, limit int) ([]string, error)
}

ThreadStore is the storage contract required by HTTP APIs.

type TurnAgentFactory

type TurnAgentFactory func(thread storage.Thread) (agents.Streamer, error)

TurnAgentFactory resolves a per-turn agent provider from thread metadata.

Jump to

Keyboard shortcuts

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