Documentation
¶
Index ¶
- Constants
- func ExtractTeamEnvFile(tags map[string]string) string
- func MergeEnvironmentVariables(cfg EnvMergeConfig) (map[string]string, error)
- type AuthInfoHandlers
- type AuthStatusResponse
- type AuthType
- type AuthTypesResponse
- type BedrockSettingsRequest
- type BedrockSettingsResponse
- type ChainCredentialProvider
- type ClaudeCredentials
- type CredentialProvider
- type CustomHandler
- type EnvCredentialProvider
- type EnvMergeConfig
- type FileCredentialProvider
- type HandlerRegistry
- type HealthHandlers
- type KubernetesSessionManager
- func (m *KubernetesSessionManager) CreateSession(ctx context.Context, id string, req *RunServerRequest) (Session, error)
- func (m *KubernetesSessionManager) DeleteSession(id string) error
- func (m *KubernetesSessionManager) GetClient() kubernetes.Interface
- func (m *KubernetesSessionManager) GetNamespace() string
- func (m *KubernetesSessionManager) GetSession(id string) Session
- func (m *KubernetesSessionManager) ListSessions(filter SessionFilter) []Session
- func (m *KubernetesSessionManager) SetSettingsRepository(repo repositories.SettingsRepository)
- func (m *KubernetesSessionManager) Shutdown(timeout time.Duration) error
- type KubernetesShareRepository
- func (r *KubernetesShareRepository) CleanupExpired() (int, error)
- func (r *KubernetesShareRepository) Delete(sessionID string) error
- func (r *KubernetesShareRepository) DeleteByToken(token string) error
- func (r *KubernetesShareRepository) FindBySessionID(sessionID string) (*SessionShare, error)
- func (r *KubernetesShareRepository) FindByToken(token string) (*SessionShare, error)
- func (r *KubernetesShareRepository) Save(share *SessionShare) error
- type KubernetesSubscriptionSecretSyncer
- type LocalSessionManager
- func (m *LocalSessionManager) CreateSession(ctx context.Context, id string, req *RunServerRequest) (Session, error)
- func (m *LocalSessionManager) DeleteSession(id string) error
- func (m *LocalSessionManager) GetLocalSession(id string) *localSession
- func (m *LocalSessionManager) GetSession(id string) Session
- func (m *LocalSessionManager) ListSessions(filter SessionFilter) []Session
- func (m *LocalSessionManager) Shutdown(timeout time.Duration) error
- type MCPServerRequest
- type MCPServerResponse
- type MarketplaceRequest
- type MarketplaceResponse
- type MemoryShareRepository
- func (r *MemoryShareRepository) CleanupExpired() (int, error)
- func (r *MemoryShareRepository) Delete(sessionID string) error
- func (r *MemoryShareRepository) DeleteByToken(token string) error
- func (r *MemoryShareRepository) FindBySessionID(sessionID string) (*SessionShare, error)
- func (r *MemoryShareRepository) FindByToken(token string) (*SessionShare, error)
- func (r *MemoryShareRepository) Save(share *SessionShare) error
- type NotificationHandlers
- func (h *NotificationHandlers) DeleteSubscription(c echo.Context) error
- func (h *NotificationHandlers) GetHistory(c echo.Context) error
- func (h *NotificationHandlers) GetSubscriptions(c echo.Context) error
- func (h *NotificationHandlers) Subscribe(c echo.Context) error
- func (h *NotificationHandlers) Webhook(c echo.Context) error
- type OAuthCallbackRequest
- type OAuthLoginRequest
- type OAuthLoginResponse
- type OAuthSession
- type OAuthSessionResponse
- type OAuthTokenResponse
- type Proxy
- func (p *Proxy) AddCustomHandler(handler CustomHandler)
- func (p *Proxy) CreateSession(sessionID string, startReq StartRequest, userID, userRole string, ...) (Session, error)
- func (p *Proxy) DeleteSessionByID(sessionID string) error
- func (p *Proxy) GetContainer() *di.Container
- func (p *Proxy) GetEcho() *echo.Echo
- func (p *Proxy) GetSessionManager() SessionManager
- func (p *Proxy) GetShareRepository() ShareRepository
- func (p *Proxy) SetSessionManager(manager SessionManager)
- func (p *Proxy) SetShareRepository(repo ShareRepository)
- func (p *Proxy) Shutdown(timeout time.Duration) error
- func (p *Proxy) StartMonitoring()
- type RepositoryInfo
- type Router
- type RunServerRequest
- type Session
- type SessionFilter
- type SessionHandlers
- func (h *SessionHandlers) DeleteSession(c echo.Context) error
- func (h *SessionHandlers) GetName() string
- func (h *SessionHandlers) RegisterRoutes(e *echo.Echo, proxy *Proxy) error
- func (h *SessionHandlers) RouteToSession(c echo.Context) error
- func (h *SessionHandlers) SearchSessions(c echo.Context) error
- func (h *SessionHandlers) StartSession(c echo.Context) error
- type SessionManager
- type SessionParams
- type SessionShare
- func (s *SessionShare) CreatedAt() time.Time
- func (s *SessionShare) CreatedBy() string
- func (s *SessionShare) ExpiresAt() *time.Time
- func (s *SessionShare) IsExpired() bool
- func (s *SessionShare) SessionID() string
- func (s *SessionShare) SetExpiresAt(expiresAt *time.Time)
- func (s *SessionShare) Token() string
- type SettingsHandlers
- func (h *SettingsHandlers) DeleteSettings(c echo.Context) error
- func (h *SettingsHandlers) GetSettings(c echo.Context) error
- func (h *SettingsHandlers) SetCredentialsSecretSyncer(syncer services.CredentialsSecretSyncer)
- func (h *SettingsHandlers) SetMCPSecretSyncer(syncer services.MCPSecretSyncer)
- func (h *SettingsHandlers) SetMarketplaceSecretSyncer(syncer services.MarketplaceSecretSyncer)
- func (h *SettingsHandlers) UpdateSettings(c echo.Context) error
- type SettingsResponse
- type ShareHandlers
- type ShareRepository
- type StartRequest
- type StartupConfig
- type StartupManager
- type UpdateSettingsRequest
- type UserHandlers
- type UserInfoResponse
Constants ¶
const ( // Environment variable names for Claude credentials EnvClaudeAccessToken = "CLAUDE_ACCESS_TOKEN" EnvClaudeRefreshToken = "CLAUDE_REFRESH_TOKEN" EnvClaudeExpiresAt = "CLAUDE_EXPIRES_AT" )
const ( ShareConfigMapName = "agentapi-session-shares" ShareConfigMapDataKey = "shares.json" LabelShare = "agentapi.proxy/shares" )
Variables ¶
This section is empty.
Functions ¶
func ExtractTeamEnvFile ¶ added in v1.48.0
ExtractTeamEnvFile extracts the env_file value from tags
func MergeEnvironmentVariables ¶ added in v1.48.0
func MergeEnvironmentVariables(cfg EnvMergeConfig) (map[string]string, error)
MergeEnvironmentVariables merges environment variables from multiple sources with the following priority (highest to lowest): 1. Request environment variables 2. Team/organization specific environment file (from tags["env_file"]) 3. Auth team environment file (from team_role_mapping) 4. Role-based environment variables
Types ¶
type AuthInfoHandlers ¶ added in v1.9.1
type AuthInfoHandlers struct {
// contains filtered or unexported fields
}
func NewAuthInfoHandlers ¶ added in v1.9.1
func NewAuthInfoHandlers(cfg *config.Config) *AuthInfoHandlers
func (*AuthInfoHandlers) GetAuthStatus ¶ added in v1.9.1
func (h *AuthInfoHandlers) GetAuthStatus(c echo.Context) error
func (*AuthInfoHandlers) GetAuthTypes ¶ added in v1.9.1
func (h *AuthInfoHandlers) GetAuthTypes(c echo.Context) error
type AuthStatusResponse ¶ added in v1.9.1
type AuthStatusResponse struct {
Authenticated bool `json:"authenticated"`
AuthType string `json:"auth_type,omitempty"`
UserID string `json:"user_id,omitempty"`
Role string `json:"role,omitempty"`
Permissions []string `json:"permissions,omitempty"`
GitHubUser *auth.GitHubUserInfo `json:"github_user,omitempty"`
}
type AuthTypesResponse ¶ added in v1.9.1
type BedrockSettingsRequest ¶ added in v1.101.0
type BedrockSettingsRequest struct {
Enabled bool `json:"enabled"`
Model string `json:"model,omitempty"`
AccessKeyID string `json:"access_key_id,omitempty"`
SecretAccessKey string `json:"secret_access_key,omitempty"`
RoleARN string `json:"role_arn,omitempty"`
Profile string `json:"profile,omitempty"`
}
BedrockSettingsRequest is the request body for Bedrock settings
type BedrockSettingsResponse ¶ added in v1.101.0
type BedrockSettingsResponse struct {
Enabled bool `json:"enabled"`
Model string `json:"model,omitempty"`
AccessKeyID string `json:"access_key_id,omitempty"`
SecretAccessKey string `json:"secret_access_key,omitempty"`
RoleARN string `json:"role_arn,omitempty"`
Profile string `json:"profile,omitempty"`
}
BedrockSettingsResponse is the response body for Bedrock settings
type ChainCredentialProvider ¶ added in v1.86.0
type ChainCredentialProvider struct {
// contains filtered or unexported fields
}
ChainCredentialProvider tries multiple providers in order until one succeeds
func NewChainCredentialProvider ¶ added in v1.86.0
func NewChainCredentialProvider(providers ...CredentialProvider) *ChainCredentialProvider
NewChainCredentialProvider creates a new ChainCredentialProvider
func (*ChainCredentialProvider) Load ¶ added in v1.86.0
func (p *ChainCredentialProvider) Load(userID string) (*ClaudeCredentials, error)
Load attempts to load credentials from each provider in order Returns the first successful result Returns nil, nil if all providers return nil
func (*ChainCredentialProvider) Name ¶ added in v1.86.0
func (p *ChainCredentialProvider) Name() string
Name returns the provider name
type ClaudeCredentials ¶ added in v1.86.0
type ClaudeCredentials struct {
AccessToken string
RefreshToken string
ExpiresAt string // epoch milliseconds as string
// RawJSON contains the original credentials.json file content
// When set, this should be used directly instead of reconstructing from fields
RawJSON []byte
}
ClaudeCredentials represents Claude authentication credentials
type CredentialProvider ¶ added in v1.86.0
type CredentialProvider interface {
// Name returns the provider name for logging purposes
Name() string
// Load attempts to load credentials from this provider for the specified user
// userID is used to locate user-specific credential files
// Returns nil, nil if credentials are not available (not an error)
// Returns nil, error if there was an error loading credentials
Load(userID string) (*ClaudeCredentials, error)
}
CredentialProvider is an interface for loading Claude credentials from various sources
func DefaultCredentialProvider ¶ added in v1.86.0
func DefaultCredentialProvider() CredentialProvider
DefaultCredentialProvider returns the default credential provider chain Order: Environment variables (highest priority) -> File
type CustomHandler ¶ added in v1.76.0
CustomHandler interface for adding custom routes
type EnvCredentialProvider ¶ added in v1.86.0
type EnvCredentialProvider struct{}
EnvCredentialProvider loads credentials from environment variables
func NewEnvCredentialProvider ¶ added in v1.86.0
func NewEnvCredentialProvider() *EnvCredentialProvider
NewEnvCredentialProvider creates a new EnvCredentialProvider
func (*EnvCredentialProvider) Load ¶ added in v1.86.0
func (p *EnvCredentialProvider) Load(_ string) (*ClaudeCredentials, error)
Load attempts to load credentials from environment variables userID is ignored for environment variable provider Returns nil, nil if CLAUDE_ACCESS_TOKEN is not set
func (*EnvCredentialProvider) Name ¶ added in v1.86.0
func (p *EnvCredentialProvider) Name() string
Name returns the provider name
type EnvMergeConfig ¶ added in v1.48.0
type EnvMergeConfig struct {
RoleEnvFiles *config.RoleEnvFilesConfig
UserRole string
TeamEnvFile string // From tags["env_file"]
AuthTeamEnvFile string // From team_role_mapping
RequestEnv map[string]string
}
EnvMergeConfig contains configuration for environment variable merging
type FileCredentialProvider ¶ added in v1.86.0
type FileCredentialProvider struct {
// contains filtered or unexported fields
}
FileCredentialProvider loads credentials from user-specific credential files When userID is provided, it looks for credentials at: $HOME/.agentapi-proxy/myclaudes/[userID]/.claude/.credentials.json When userID is empty, it falls back to ~/.claude/.credentials.json
func NewFileCredentialProvider ¶ added in v1.86.0
func NewFileCredentialProvider() *FileCredentialProvider
NewFileCredentialProvider creates a new FileCredentialProvider with default path
func NewFileCredentialProviderWithPath ¶ added in v1.86.0
func NewFileCredentialProviderWithPath(path string) *FileCredentialProvider
NewFileCredentialProviderWithPath creates a new FileCredentialProvider with custom path This is primarily used for testing
func (*FileCredentialProvider) Load ¶ added in v1.86.0
func (p *FileCredentialProvider) Load(userID string) (*ClaudeCredentials, error)
Load attempts to load credentials from the file If userID is provided, looks in the user-specific directory Returns nil, nil if the file doesn't exist Returns nil, error if there was an error reading the file
func (*FileCredentialProvider) Name ¶ added in v1.86.0
func (p *FileCredentialProvider) Name() string
Name returns the provider name
type HandlerRegistry ¶ added in v1.76.0
type HandlerRegistry struct {
// contains filtered or unexported fields
}
HandlerRegistry contains all handlers
type HealthHandlers ¶ added in v1.76.0
type HealthHandlers struct{}
HealthHandlers handles health check endpoints
func NewHealthHandlers ¶ added in v1.76.0
func NewHealthHandlers() *HealthHandlers
NewHealthHandlers creates a new HealthHandlers instance
func (*HealthHandlers) HealthCheck ¶ added in v1.76.0
func (h *HealthHandlers) HealthCheck(c echo.Context) error
HealthCheck handles GET /health requests to check server health
type KubernetesSessionManager ¶ added in v1.84.0
type KubernetesSessionManager struct {
// contains filtered or unexported fields
}
KubernetesSessionManager manages sessions using Kubernetes Deployments
func NewKubernetesSessionManager ¶ added in v1.84.0
func NewKubernetesSessionManager( cfg *config.Config, verbose bool, lgr *logger.Logger, ) (*KubernetesSessionManager, error)
NewKubernetesSessionManager creates a new KubernetesSessionManager
func NewKubernetesSessionManagerWithClient ¶ added in v1.84.0
func NewKubernetesSessionManagerWithClient( cfg *config.Config, verbose bool, lgr *logger.Logger, client kubernetes.Interface, ) (*KubernetesSessionManager, error)
NewKubernetesSessionManagerWithClient creates a new KubernetesSessionManager with a custom client This is useful for testing with a fake client
func (*KubernetesSessionManager) CreateSession ¶ added in v1.84.0
func (m *KubernetesSessionManager) CreateSession(ctx context.Context, id string, req *RunServerRequest) (Session, error)
CreateSession creates a new session with a Kubernetes Deployment
func (*KubernetesSessionManager) DeleteSession ¶ added in v1.84.0
func (m *KubernetesSessionManager) DeleteSession(id string) error
DeleteSession stops and removes a session If the session is not in memory, it attempts to restore from Kubernetes Service first
func (*KubernetesSessionManager) GetClient ¶ added in v1.90.0
func (m *KubernetesSessionManager) GetClient() kubernetes.Interface
GetClient returns the Kubernetes client (used by subscription secret syncer)
func (*KubernetesSessionManager) GetNamespace ¶ added in v1.90.0
func (m *KubernetesSessionManager) GetNamespace() string
GetNamespace returns the Kubernetes namespace (used by subscription secret syncer)
func (*KubernetesSessionManager) GetSession ¶ added in v1.84.0
func (m *KubernetesSessionManager) GetSession(id string) Session
GetSession returns a session by ID If the session is not in memory, it attempts to restore from Kubernetes Service
func (*KubernetesSessionManager) ListSessions ¶ added in v1.84.0
func (m *KubernetesSessionManager) ListSessions(filter SessionFilter) []Session
ListSessions returns all sessions matching the filter Sessions are retrieved from Kubernetes Services to survive proxy restarts
func (*KubernetesSessionManager) SetSettingsRepository ¶ added in v1.101.0
func (m *KubernetesSessionManager) SetSettingsRepository(repo repositories.SettingsRepository)
SetSettingsRepository sets the settings repository for Bedrock configuration
func (*KubernetesSessionManager) Shutdown ¶ added in v1.84.0
func (m *KubernetesSessionManager) Shutdown(timeout time.Duration) error
Shutdown gracefully stops all sessions Note: This does NOT delete Kubernetes resources (Deployment, Service, PVC, Secret). Resources are preserved so sessions can be restored when the proxy restarts. Use DeleteSession to explicitly delete a session and its resources.
type KubernetesShareRepository ¶ added in v1.136.0
type KubernetesShareRepository struct {
// contains filtered or unexported fields
}
KubernetesShareRepository implements ShareRepository using Kubernetes ConfigMap
func NewKubernetesShareRepository ¶ added in v1.136.0
func NewKubernetesShareRepository(client kubernetes.Interface, namespace string) *KubernetesShareRepository
NewKubernetesShareRepository creates a new KubernetesShareRepository
func (*KubernetesShareRepository) CleanupExpired ¶ added in v1.136.0
func (r *KubernetesShareRepository) CleanupExpired() (int, error)
CleanupExpired removes all expired shares
func (*KubernetesShareRepository) Delete ¶ added in v1.136.0
func (r *KubernetesShareRepository) Delete(sessionID string) error
Delete removes a share by session ID
func (*KubernetesShareRepository) DeleteByToken ¶ added in v1.136.0
func (r *KubernetesShareRepository) DeleteByToken(token string) error
DeleteByToken removes a share by token
func (*KubernetesShareRepository) FindBySessionID ¶ added in v1.136.0
func (r *KubernetesShareRepository) FindBySessionID(sessionID string) (*SessionShare, error)
FindBySessionID retrieves a share by session ID
func (*KubernetesShareRepository) FindByToken ¶ added in v1.136.0
func (r *KubernetesShareRepository) FindByToken(token string) (*SessionShare, error)
FindByToken retrieves a share by its token
func (*KubernetesShareRepository) Save ¶ added in v1.136.0
func (r *KubernetesShareRepository) Save(share *SessionShare) error
Save persists a session share
type KubernetesSubscriptionSecretSyncer ¶ added in v1.90.0
type KubernetesSubscriptionSecretSyncer struct {
// contains filtered or unexported fields
}
KubernetesSubscriptionSecretSyncer syncs subscription data to Kubernetes Secrets
func NewKubernetesSubscriptionSecretSyncer ¶ added in v1.90.0
func NewKubernetesSubscriptionSecretSyncer( clientset kubernetes.Interface, namespace string, storage notification.Storage, secretPrefix string, ) *KubernetesSubscriptionSecretSyncer
NewKubernetesSubscriptionSecretSyncer creates a new KubernetesSubscriptionSecretSyncer
func (*KubernetesSubscriptionSecretSyncer) GetSecretName ¶ added in v1.90.0
func (s *KubernetesSubscriptionSecretSyncer) GetSecretName(userID string) string
GetSecretName returns the secret name for a given user ID
func (*KubernetesSubscriptionSecretSyncer) Sync ¶ added in v1.90.0
func (s *KubernetesSubscriptionSecretSyncer) Sync(userID string) error
Sync creates or updates the subscription Secret for a user
type LocalSessionManager ¶ added in v1.83.0
type LocalSessionManager struct {
// contains filtered or unexported fields
}
LocalSessionManager manages sessions using local processes
func NewLocalSessionManager ¶ added in v1.83.0
func NewLocalSessionManager(cfg *config.Config, verbose bool, lgr *logger.Logger, startPort int) *LocalSessionManager
NewLocalSessionManager creates a new LocalSessionManager
func (*LocalSessionManager) CreateSession ¶ added in v1.83.0
func (m *LocalSessionManager) CreateSession(ctx context.Context, id string, req *RunServerRequest) (Session, error)
CreateSession creates a new session and starts it
func (*LocalSessionManager) DeleteSession ¶ added in v1.83.0
func (m *LocalSessionManager) DeleteSession(id string) error
DeleteSession stops and removes a session
func (*LocalSessionManager) GetLocalSession ¶ added in v1.83.0
func (m *LocalSessionManager) GetLocalSession(id string) *localSession
GetLocalSession returns the internal localSession for handlers that need it
func (*LocalSessionManager) GetSession ¶ added in v1.83.0
func (m *LocalSessionManager) GetSession(id string) Session
GetSession returns a session by ID, nil if not found
func (*LocalSessionManager) ListSessions ¶ added in v1.83.0
func (m *LocalSessionManager) ListSessions(filter SessionFilter) []Session
ListSessions returns all sessions matching the filter
type MCPServerRequest ¶ added in v1.124.0
type MCPServerRequest struct {
Type string `json:"type"` // "stdio", "http", "sse"
URL string `json:"url,omitempty"` // for http/sse
Command string `json:"command,omitempty"` // for stdio
Args []string `json:"args,omitempty"` // for stdio
Env map[string]string `json:"env,omitempty"` // environment variables
Headers map[string]string `json:"headers,omitempty"` // for http/sse
}
MCPServerRequest is the request body for a single MCP server
type MCPServerResponse ¶ added in v1.124.0
type MCPServerResponse struct {
Type string `json:"type"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
EnvKeys []string `json:"env_keys,omitempty"` // only keys, not values
HeaderKeys []string `json:"header_keys,omitempty"` // only keys, not values
}
MCPServerResponse is the response body for a single MCP server
type MarketplaceRequest ¶ added in v1.129.0
type MarketplaceRequest struct {
URL string `json:"url"`
}
MarketplaceRequest is the request body for a single marketplace
type MarketplaceResponse ¶ added in v1.129.0
type MarketplaceResponse struct {
URL string `json:"url"`
}
MarketplaceResponse is the response body for a single marketplace
type MemoryShareRepository ¶ added in v1.136.0
type MemoryShareRepository struct {
// contains filtered or unexported fields
}
MemoryShareRepository is an in-memory implementation of ShareRepository
func NewMemoryShareRepository ¶ added in v1.136.0
func NewMemoryShareRepository() *MemoryShareRepository
NewMemoryShareRepository creates a new MemoryShareRepository
func (*MemoryShareRepository) CleanupExpired ¶ added in v1.136.0
func (r *MemoryShareRepository) CleanupExpired() (int, error)
CleanupExpired removes all expired shares
func (*MemoryShareRepository) Delete ¶ added in v1.136.0
func (r *MemoryShareRepository) Delete(sessionID string) error
Delete removes a share by session ID
func (*MemoryShareRepository) DeleteByToken ¶ added in v1.136.0
func (r *MemoryShareRepository) DeleteByToken(token string) error
DeleteByToken removes a share by token
func (*MemoryShareRepository) FindBySessionID ¶ added in v1.136.0
func (r *MemoryShareRepository) FindBySessionID(sessionID string) (*SessionShare, error)
FindBySessionID retrieves a share by session ID
func (*MemoryShareRepository) FindByToken ¶ added in v1.136.0
func (r *MemoryShareRepository) FindByToken(token string) (*SessionShare, error)
FindByToken retrieves a share by its token
func (*MemoryShareRepository) Save ¶ added in v1.136.0
func (r *MemoryShareRepository) Save(share *SessionShare) error
Save persists a session share
type NotificationHandlers ¶ added in v1.59.0
type NotificationHandlers struct {
// contains filtered or unexported fields
}
NotificationHandlers handles notification-related HTTP requests
func NewNotificationHandlers ¶ added in v1.59.0
func NewNotificationHandlers(service *notification.Service) *NotificationHandlers
NewNotificationHandlers creates new notification handlers
func (*NotificationHandlers) DeleteSubscription ¶ added in v1.59.0
func (h *NotificationHandlers) DeleteSubscription(c echo.Context) error
DeleteSubscription handles DELETE /notification/subscribe
func (*NotificationHandlers) GetHistory ¶ added in v1.59.0
func (h *NotificationHandlers) GetHistory(c echo.Context) error
GetHistory handles GET /notifications/history
func (*NotificationHandlers) GetSubscriptions ¶ added in v1.59.0
func (h *NotificationHandlers) GetSubscriptions(c echo.Context) error
GetSubscriptions handles GET /notification/subscribe
type OAuthCallbackRequest ¶ added in v1.9.1
OAuthCallbackRequest represents the OAuth callback parameters
type OAuthLoginRequest ¶ added in v1.9.1
type OAuthLoginRequest struct {
RedirectURI string `json:"redirect_uri"`
}
OAuthLoginRequest represents the request body for OAuth login
type OAuthLoginResponse ¶ added in v1.9.1
OAuthLoginResponse represents the response for OAuth login
type OAuthSession ¶ added in v1.9.1
type OAuthSession struct {
ID string
UserContext *auth.UserContext
CreatedAt time.Time
ExpiresAt time.Time
}
OAuthSession represents an authenticated OAuth session
type OAuthSessionResponse ¶ added in v1.9.1
type OAuthSessionResponse struct {
SessionID string `json:"session_id"`
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresAt time.Time `json:"expires_at"`
User *auth.UserContext `json:"user"`
}
OAuthSessionResponse represents the response with session information
type OAuthTokenResponse ¶ added in v1.9.1
type OAuthTokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresAt time.Time `json:"expires_at"`
User *auth.UserContext `json:"user"`
}
OAuthTokenResponse represents the response after successful OAuth
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy represents the HTTP proxy server
func (*Proxy) AddCustomHandler ¶ added in v1.117.0
func (p *Proxy) AddCustomHandler(handler CustomHandler)
AddCustomHandler adds a custom handler to the router
func (*Proxy) CreateSession ¶ added in v1.76.0
func (p *Proxy) CreateSession(sessionID string, startReq StartRequest, userID, userRole string, teams []string) (Session, error)
CreateSession creates a new agent session
func (*Proxy) DeleteSessionByID ¶ added in v1.76.0
DeleteSessionByID deletes a session by ID
func (*Proxy) GetContainer ¶ added in v1.76.0
GetContainer returns the DI container
func (*Proxy) GetSessionManager ¶ added in v1.83.0
func (p *Proxy) GetSessionManager() SessionManager
GetSessionManager returns the session manager
func (*Proxy) GetShareRepository ¶ added in v1.138.0
func (p *Proxy) GetShareRepository() ShareRepository
GetShareRepository returns the share repository
func (*Proxy) SetSessionManager ¶ added in v1.83.0
func (p *Proxy) SetSessionManager(manager SessionManager)
SetSessionManager allows configuration of a custom session manager (for testing)
func (*Proxy) SetShareRepository ¶ added in v1.138.0
func (p *Proxy) SetShareRepository(repo ShareRepository)
SetShareRepository allows configuration of a custom share repository (for testing)
func (*Proxy) Shutdown ¶
Shutdown gracefully stops all running sessions and waits for them to terminate
func (*Proxy) StartMonitoring ¶ added in v1.62.0
func (p *Proxy) StartMonitoring()
StartMonitoring starts the session monitoring (called after proxy is fully initialized)
type RepositoryInfo ¶ added in v0.10.0
RepositoryInfo contains repository information extracted from tags
func ExtractRepositoryInfo ¶ added in v1.125.0
func ExtractRepositoryInfo(tags map[string]string, cloneDir string) *RepositoryInfo
ExtractRepositoryInfo extracts repository information from tags. This is a public function that can be used by other packages (e.g., schedule). The cloneDir parameter is typically the session ID.
type Router ¶ added in v1.76.0
type Router struct {
// contains filtered or unexported fields
}
Router handles route registration and management
func (*Router) AddCustomHandler ¶ added in v1.76.0
func (r *Router) AddCustomHandler(handler CustomHandler)
AddCustomHandler adds a custom handler to the registry
func (*Router) RegisterRoutes ¶ added in v1.76.0
RegisterRoutes registers all routes
type RunServerRequest ¶ added in v1.82.0
type RunServerRequest struct {
Port int
UserID string
Environment map[string]string
Tags map[string]string
RepoInfo *RepositoryInfo
InitialMessage string
Teams []string // GitHub team slugs (e.g., ["org/team-a", "org/team-b"])
GithubToken string // GitHub token passed via params.github_token
}
RunServerRequest contains parameters needed to run an agentapi server
type Session ¶ added in v1.83.0
type Session interface {
// ID returns the unique session identifier
ID() string
// Addr returns the address (host:port) the session is running on
// For local sessions, this returns "localhost:{port}"
// For Kubernetes sessions, this returns "{service-dns}:{port}"
Addr() string
// UserID returns the user ID that owns this session
UserID() string
// Tags returns the session tags
Tags() map[string]string
// Status returns the current status of the session
Status() string
// StartedAt returns when the session was started
StartedAt() time.Time
// Description returns the session description
// Returns tags["description"] if exists, otherwise returns InitialMessage
Description() string
// Cancel cancels the session context to trigger shutdown
Cancel()
}
Session represents a running agentapi session
type SessionFilter ¶ added in v1.83.0
SessionFilter defines filter criteria for listing sessions
type SessionHandlers ¶ added in v1.77.0
type SessionHandlers struct {
// contains filtered or unexported fields
}
SessionHandlers handles session management endpoints without persistence
func NewSessionHandlers ¶ added in v1.77.0
func NewSessionHandlers(proxy *Proxy) *SessionHandlers
NewSessionHandlers creates a new SessionHandlers instance
func (*SessionHandlers) DeleteSession ¶ added in v1.77.0
func (h *SessionHandlers) DeleteSession(c echo.Context) error
DeleteSession handles DELETE /sessions/:sessionId requests to terminate a session
func (*SessionHandlers) GetName ¶ added in v1.77.0
func (h *SessionHandlers) GetName() string
GetName returns the name of this handler for logging
func (*SessionHandlers) RegisterRoutes ¶ added in v1.77.0
func (h *SessionHandlers) RegisterRoutes(e *echo.Echo, proxy *Proxy) error
RegisterRoutes registers session management routes
func (*SessionHandlers) RouteToSession ¶ added in v1.77.0
func (h *SessionHandlers) RouteToSession(c echo.Context) error
RouteToSession routes requests to the appropriate agentapi server instance
func (*SessionHandlers) SearchSessions ¶ added in v1.77.0
func (h *SessionHandlers) SearchSessions(c echo.Context) error
SearchSessions handles GET /search requests to list and filter active sessions (memory only)
func (*SessionHandlers) StartSession ¶ added in v1.77.0
func (h *SessionHandlers) StartSession(c echo.Context) error
StartSession handles POST /start requests to start a new agentapi server
type SessionManager ¶ added in v1.83.0
type SessionManager interface {
// CreateSession creates a new session and starts it
CreateSession(ctx context.Context, id string, req *RunServerRequest) (Session, error)
// GetSession returns a session by ID, nil if not found
GetSession(id string) Session
// ListSessions returns all sessions matching the filter
ListSessions(filter SessionFilter) []Session
// DeleteSession stops and removes a session
DeleteSession(id string) error
// Shutdown gracefully stops all sessions
Shutdown(timeout time.Duration) error
}
SessionManager manages the lifecycle of sessions
type SessionParams ¶ added in v1.98.0
type SessionParams struct {
// Message is the initial message to send to the agent after session starts
Message string `json:"message,omitempty"`
// GithubToken is a GitHub token to use for authentication instead of GitHub App
GithubToken string `json:"github_token,omitempty"`
}
SessionParams represents session parameters for agentapi server
type SessionShare ¶ added in v1.136.0
type SessionShare struct {
// contains filtered or unexported fields
}
SessionShare represents a shared session link
func NewSessionShare ¶ added in v1.136.0
func NewSessionShare(sessionID, createdBy string) *SessionShare
NewSessionShare creates a new SessionShare
func NewSessionShareWithToken ¶ added in v1.136.0
func NewSessionShareWithToken(token, sessionID, createdBy string, createdAt time.Time, expiresAt *time.Time) *SessionShare
NewSessionShareWithToken creates a SessionShare with a specific token (for loading from storage)
func (*SessionShare) CreatedAt ¶ added in v1.136.0
func (s *SessionShare) CreatedAt() time.Time
CreatedAt returns when the share was created
func (*SessionShare) CreatedBy ¶ added in v1.136.0
func (s *SessionShare) CreatedBy() string
CreatedBy returns the user who created the share
func (*SessionShare) ExpiresAt ¶ added in v1.136.0
func (s *SessionShare) ExpiresAt() *time.Time
ExpiresAt returns when the share expires (nil if no expiration)
func (*SessionShare) IsExpired ¶ added in v1.136.0
func (s *SessionShare) IsExpired() bool
IsExpired returns true if the share has expired
func (*SessionShare) SessionID ¶ added in v1.136.0
func (s *SessionShare) SessionID() string
SessionID returns the session ID
func (*SessionShare) SetExpiresAt ¶ added in v1.136.0
func (s *SessionShare) SetExpiresAt(expiresAt *time.Time)
SetExpiresAt sets the expiration time
func (*SessionShare) Token ¶ added in v1.136.0
func (s *SessionShare) Token() string
Token returns the share token
type SettingsHandlers ¶ added in v1.101.0
type SettingsHandlers struct {
// contains filtered or unexported fields
}
SettingsHandlers handles settings-related HTTP requests
func NewSettingsHandlers ¶ added in v1.101.0
func NewSettingsHandlers(repo repositories.SettingsRepository) *SettingsHandlers
NewSettingsHandlers creates new settings handlers
func (*SettingsHandlers) DeleteSettings ¶ added in v1.101.0
func (h *SettingsHandlers) DeleteSettings(c echo.Context) error
DeleteSettings handles DELETE /settings/:name
func (*SettingsHandlers) GetSettings ¶ added in v1.101.0
func (h *SettingsHandlers) GetSettings(c echo.Context) error
GetSettings handles GET /settings/:name
func (*SettingsHandlers) SetCredentialsSecretSyncer ¶ added in v1.106.0
func (h *SettingsHandlers) SetCredentialsSecretSyncer(syncer services.CredentialsSecretSyncer)
SetCredentialsSecretSyncer sets the credentials secret syncer
func (*SettingsHandlers) SetMCPSecretSyncer ¶ added in v1.124.0
func (h *SettingsHandlers) SetMCPSecretSyncer(syncer services.MCPSecretSyncer)
SetMCPSecretSyncer sets the MCP secret syncer
func (*SettingsHandlers) SetMarketplaceSecretSyncer ¶ added in v1.129.0
func (h *SettingsHandlers) SetMarketplaceSecretSyncer(syncer services.MarketplaceSecretSyncer)
SetMarketplaceSecretSyncer sets the marketplace secret syncer
func (*SettingsHandlers) UpdateSettings ¶ added in v1.101.0
func (h *SettingsHandlers) UpdateSettings(c echo.Context) error
UpdateSettings handles PUT /settings/:name
type SettingsResponse ¶ added in v1.101.0
type SettingsResponse struct {
Name string `json:"name"`
Bedrock *BedrockSettingsResponse `json:"bedrock,omitempty"`
MCPServers map[string]*MCPServerResponse `json:"mcp_servers,omitempty"`
Marketplaces map[string]*MarketplaceResponse `json:"marketplaces,omitempty"`
EnabledPlugins []string `json:"enabled_plugins,omitempty"` // plugin@marketplace format
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
SettingsResponse is the response body for settings
type ShareHandlers ¶ added in v1.136.0
type ShareHandlers struct {
// contains filtered or unexported fields
}
ShareHandlers handles session sharing endpoints
func NewShareHandlers ¶ added in v1.136.0
func NewShareHandlers(proxy *Proxy, shareRepo ShareRepository) *ShareHandlers
NewShareHandlers creates a new ShareHandlers instance
func (*ShareHandlers) CreateShare ¶ added in v1.136.0
func (h *ShareHandlers) CreateShare(c echo.Context) error
CreateShare handles POST /sessions/:sessionId/share to create a share URL
func (*ShareHandlers) DeleteShare ¶ added in v1.136.0
func (h *ShareHandlers) DeleteShare(c echo.Context) error
DeleteShare handles DELETE /sessions/:sessionId/share to revoke share
func (*ShareHandlers) GetName ¶ added in v1.136.0
func (h *ShareHandlers) GetName() string
GetName returns the name of this handler for logging
func (*ShareHandlers) GetShare ¶ added in v1.136.0
func (h *ShareHandlers) GetShare(c echo.Context) error
GetShare handles GET /sessions/:sessionId/share to get share status
func (*ShareHandlers) RouteToSharedSession ¶ added in v1.136.0
func (h *ShareHandlers) RouteToSharedSession(c echo.Context) error
RouteToSharedSession handles ANY /s/:shareToken/* to access shared session
type ShareRepository ¶ added in v1.136.0
type ShareRepository interface {
Save(share *SessionShare) error
FindByToken(token string) (*SessionShare, error)
FindBySessionID(sessionID string) (*SessionShare, error)
Delete(sessionID string) error
DeleteByToken(token string) error
CleanupExpired() (int, error)
}
ShareRepository defines the interface for share storage
type StartRequest ¶
type StartRequest struct {
Environment map[string]string `json:"environment,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
// Params contains session parameters
Params *SessionParams `json:"params,omitempty"`
}
StartRequest represents the request body for starting a new agentapi server
type StartupConfig ¶ added in v1.41.3
type StartupConfig struct {
Port int
UserID string
RepoFullName string
CloneDir string
GitHubToken string
GitHubAppID string
GitHubInstallationID string
GitHubAppPEMPath string
GitHubAPI string
GitHubPersonalAccessToken string
MCPConfigs string
AgentAPIArgs string
ClaudeArgs string
Environment map[string]string
Config *config.Config
Verbose bool
IsRestore bool // Whether this is a restored session
}
StartupConfig holds configuration for session startup
type StartupManager ¶ added in v1.41.3
type StartupManager struct {
// contains filtered or unexported fields
}
StartupManager manages the startup process
func NewStartupManager ¶ added in v1.41.3
func NewStartupManager(config *config.Config, verbose bool) *StartupManager
NewStartupManager creates a new startup manager
func (*StartupManager) StartAgentAPISession ¶ added in v1.41.3
func (sm *StartupManager) StartAgentAPISession(ctx context.Context, cfg *StartupConfig) (*exec.Cmd, error)
StartAgentAPISession starts an AgentAPI session with the given configuration
type UpdateSettingsRequest ¶ added in v1.101.0
type UpdateSettingsRequest struct {
Bedrock *BedrockSettingsRequest `json:"bedrock"`
MCPServers map[string]*MCPServerRequest `json:"mcp_servers,omitempty"`
Marketplaces map[string]*MarketplaceRequest `json:"marketplaces,omitempty"`
EnabledPlugins []string `json:"enabled_plugins,omitempty"` // plugin@marketplace format
}
UpdateSettingsRequest is the request body for updating settings
type UserHandlers ¶ added in v1.103.0
type UserHandlers struct {
// contains filtered or unexported fields
}
UserHandlers handles user-related endpoints
func NewUserHandlers ¶ added in v1.103.0
func NewUserHandlers(proxy *Proxy) *UserHandlers
NewUserHandlers creates a new UserHandlers instance
func (*UserHandlers) GetUserInfo ¶ added in v1.103.0
func (h *UserHandlers) GetUserInfo(c echo.Context) error
GetUserInfo handles GET /user/info requests
type UserInfoResponse ¶ added in v1.103.0
UserInfoResponse represents the response for /user/info endpoint
Source Files
¶
- auth_info_handlers.go
- credential_provider.go
- credential_provider_chain.go
- credential_provider_env.go
- credential_provider_file.go
- env_merge.go
- health_handlers.go
- kubernetes_session.go
- kubernetes_session_manager.go
- local_session_manager.go
- notification_handlers_new.go
- oauth_handlers.go
- proxy.go
- router.go
- session.go
- session_handlers.go
- settings_handlers.go
- share.go
- share_handlers.go
- share_repository.go
- startup.go
- subscription_secret_syncer_k8s.go
- types.go
- user_handlers.go